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 |
|---|---|---|---|---|---|---|
Yield successive nsized chunks from lst. | def chunks(lst, n):
for i in range(0, len(lst), n):
yield lst[i:i + n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunks(self, lst, n):\n for i in range(0, len(lst), n):\n yield lst[i:i + n]",
"def chunks(lst: list, n: int):\n for i in range(0, len(lst), n):\n yield lst[i : i + n]",
"def chunks(lst, n):\n for i in range(0, len(lst), n):\n yield lst[i:i + n]",
"de... | [
"0.83071756",
"0.81939614",
"0.81910837",
"0.81910837",
"0.8190213",
"0.81267184",
"0.81218547",
"0.81218547",
"0.80773693",
"0.80526286",
"0.80526286",
"0.80526286",
"0.80526286",
"0.80526286",
"0.80042696",
"0.7871678",
"0.7845623",
"0.7828392",
"0.7827006",
"0.78138447",
"... | 0.80533457 | 20 |
Constructor for a Neuron object | def __init__(self, weights):
if len(weights) == 0:
raise Exception("Error: Invalid input weights")
self._weights = weights | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, nx):\n if not isinstance(nx, int):\n raise TypeError('nx must be an integer')\n if nx < 1:\n raise ValueError('nx must be a positive integer')\n\n \"\"\"\n W = The weights vector for the neuron. Upon instantiation\n using a random normal d... | [
"0.79738605",
"0.7597465",
"0.7353959",
"0.7231481",
"0.7207281",
"0.7183412",
"0.70984834",
"0.7091131",
"0.7090566",
"0.7077017",
"0.7047264",
"0.702352",
"0.7021905",
"0.7018575",
"0.7009885",
"0.69210434",
"0.6920294",
"0.6898878",
"0.6868661",
"0.68676364",
"0.6855767",
... | 0.0 | -1 |
Update the current weight with the given weight delta | def update_weights(self, weight_delta):
self._weights = math_util.vector_sum(self._weights, weight_delta) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_weights(self):\n self._weights = self._weights + self.update_weights_value",
"def update_weights(self):\n\t\tpass",
"def update_weights(self):\n self._weights = self._weights + self.update_weights_value\n self.weights_clipping()",
"def update_weight(self,ctr,new_weight):\n ... | [
"0.79364264",
"0.76176095",
"0.75691634",
"0.7566814",
"0.75202656",
"0.7497759",
"0.74281836",
"0.7407178",
"0.7337497",
"0.7301701",
"0.7270133",
"0.7265375",
"0.7262237",
"0.714753",
"0.71333677",
"0.7102003",
"0.7041415",
"0.7021671",
"0.70161235",
"0.69539577",
"0.690912... | 0.8541726 | 0 |
Deletes the agent element on the canvas, and redraws it at the new state location | def update(self, new_state):
if self.update_animation:
self.canvas.delete(self.agent)
row, col = new_state
x1 = col * self.GRID_ROW_HEIGHT
y1 = row * self.GRID_ROW_HEIGHT
self.agent = self.canvas.create_image(x1 + self.GRID_ROW_HEIGHT / 2, y1 + self.G... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self):\n\t\tself.canvas.delete('node_'+self.identifier)\n\t\tself.canvas.tag_unbind('node_'+self.identifier,\"<Any>\")",
"def delete_ball(self):\r\n self.movement = \"\"\r\n self.canvas.delete(self.ball)",
"def undraw(self):\n \n if not self.canvas: return\n if not... | [
"0.6978077",
"0.6698394",
"0.63849384",
"0.63558096",
"0.6339495",
"0.6298731",
"0.6262945",
"0.62217695",
"0.6190558",
"0.616468",
"0.61136556",
"0.61136556",
"0.6109834",
"0.60887885",
"0.60701597",
"0.6048633",
"0.601569",
"0.599125",
"0.5968352",
"0.5968352",
"0.59576297"... | 0.6304387 | 5 |
Deletes the agent element on the canvas, and redraws it at the start location | def restart_environment(self, start_state):
if self.update_animation:
self.canvas.delete(self.agent)
row, col = start_state
x1 = col * self.GRID_ROW_HEIGHT
y1 = row * self.GRID_ROW_HEIGHT
self.agent = self.canvas.create_image(x1 + self.GRID_ROW_HEIGHT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self):\n\t\tself.canvas.delete('node_'+self.identifier)\n\t\tself.canvas.tag_unbind('node_'+self.identifier,\"<Any>\")",
"def delete_ball(self):\r\n self.movement = \"\"\r\n self.canvas.delete(self.ball)",
"def clear_canvas():\n self.parent_class.canvas.delete(\"all\")",
"... | [
"0.6850116",
"0.67763364",
"0.66194516",
"0.6546015",
"0.6516195",
"0.6437526",
"0.6368342",
"0.635552",
"0.63020915",
"0.62905496",
"0.62492776",
"0.62403834",
"0.6193632",
"0.6142521",
"0.6142521",
"0.6109802",
"0.610264",
"0.6091745",
"0.60832644",
"0.6077725",
"0.6076658"... | 0.6123724 | 15 |
If the provided HTTP request header contains a 'updatedSince' value, parses the value and returns it as a number of seconds since 1970. | def resolveUpdatedSinceArg(request):
if 'updatedSince' in request.arguments:
us = request.arguments['updatedSince'][0]
# value space of US is an XML Schema DateTime
#return time.strptime(us, "%Y-%m-%dT%H:%M:%S%Z")
ma = dateTimeRE.match(us)
m = ma.groupdict()
year = 0
if m['year']:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seconds_from_last_update(self):\n return (datetime.utcnow() - self.last_update_datetime).total_seconds()",
"def since(self, seconds=None):\r\n url = '{0}/{1}'.format(self.get_pull_url(), 'since')\r\n params = base.get_params(('seconds',), locals())\r\n\r\n return http.Request('GET... | [
"0.6073428",
"0.58592075",
"0.5749036",
"0.57252103",
"0.56871647",
"0.56829596",
"0.5681911",
"0.5597623",
"0.5597623",
"0.5570426",
"0.55699205",
"0.5503255",
"0.5460118",
"0.54585403",
"0.5436943",
"0.54296196",
"0.5428707",
"0.54115844",
"0.5392215",
"0.5388706",
"0.53838... | 0.68917334 | 0 |
Pushes a diagnostic to the inflight diagnostics stack. | def push_inflight_diagnostic(self, diagnostic: Diagnostic) -> None:
self._inflight_diagnostics.append(diagnostic) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_inflight_diagnostic(\n self, diagnostic: Diagnostic\n ) -> Generator[Diagnostic, None, None]:\n self._inflight_diagnostics.append(diagnostic)\n try:\n yield diagnostic\n finally:\n self._inflight_diagnostics.pop()",
"def append_diagnostic(self, diagnos... | [
"0.6217021",
"0.618841",
"0.57341397",
"0.55969477",
"0.5326345",
"0.52847344",
"0.52583814",
"0.5046785",
"0.5046785",
"0.5035475",
"0.4979315",
"0.49768132",
"0.49152374",
"0.49132392",
"0.48740172",
"0.48603904",
"0.48577407",
"0.48576224",
"0.4847173",
"0.48314714",
"0.48... | 0.82572174 | 0 |
Return true if the queue is not empty | def __bool__(self):
return not self.empty() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(self):\n return self.queue == []",
"def is_empty(self):\n return len(self.__queue) > 0",
"def is_empty(self):\n return len(self.queue) == 0",
"def is_empty(self):\n return len(self.queue) == 0",
"def empty(self):\r\n return self.queue == []",
"def is_empty(... | [
"0.9118835",
"0.90226334",
"0.90096045",
"0.90096045",
"0.89602274",
"0.89586806",
"0.8947663",
"0.8911488",
"0.8892824",
"0.88819426",
"0.88758475",
"0.8866937",
"0.8796679",
"0.8788819",
"0.87555903",
"0.87411493",
"0.87411493",
"0.8708874",
"0.8636329",
"0.860362",
"0.8569... | 0.0 | -1 |
Get the environment config file. | def get_env_conf(self):
conf = os.path.join(self.juju_home, 'environments.yaml')
if not os.path.exists(conf):
raise ConfigError("Juju environments.yaml not found %s" % conf)
return conf | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config_file():\n return deployr_config_repository.get_deployr_config_file()",
"def config_file(self):\n return self[CONFIG_FILE_KEY]",
"def get_config_path() -> Path:\n config = os.getenv('TOM_CONFIG', '')\n return Path(config)",
"def get_config(_config_file):\n ''' script abso... | [
"0.7840051",
"0.7779786",
"0.75120795",
"0.74376327",
"0.7372582",
"0.7329114",
"0.73032075",
"0.7278699",
"0.72614646",
"0.7240988",
"0.72286487",
"0.7194988",
"0.71946055",
"0.7146135",
"0.7136438",
"0.7124891",
"0.71054673",
"0.7084764",
"0.707211",
"0.70672953",
"0.705607... | 0.7823943 | 1 |
returns a json set of documents with the given attributes | def search(
self,
page_size,
page_num,
brand=None,
model=None,
price_min=None,
price_max=None,
year_min=None,
year_max=None
):
skips = page_size * (page_num - 1)
condition_list = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def documents(required_fields=None,\n optional_fields=None,\n random_fields=json.values()):\n return json.objects(required_fields=required_fields,\n optional_fields=optional_fields,\n elements=random_fields)",
"def get(self):\n que... | [
"0.6897233",
"0.6227147",
"0.61913586",
"0.59923625",
"0.5919395",
"0.57320637",
"0.57306385",
"0.57058734",
"0.55986124",
"0.55965334",
"0.55608904",
"0.5548245",
"0.5530532",
"0.55280334",
"0.5478374",
"0.5478374",
"0.5461847",
"0.54339606",
"0.5407311",
"0.5392416",
"0.537... | 0.0 | -1 |
Convenience method to return an Instagram object with the default credentials/setup | def default_client():
credential_manager = CredentialManager()
current_directory = os.path.abspath(inspect.getfile(inspect.currentframe()))
save_file_path = os.path.dirname(current_directory)
insta_username, insta_password = credential_manager.get_account('Instagram')
mon... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, username = None, password = None):\n self.username = config['AUTH']['USERNAME']\n self.password = config['AUTH']['PASSWORD']\n self.login = config['URL']['LOGIN']\n self.nav_url = config['URL']['NAV']\n self.tag_url = config['URL']['TAGS']\n self.direct_... | [
"0.6764892",
"0.607418",
"0.58953965",
"0.58937913",
"0.58239806",
"0.57799137",
"0.57614213",
"0.5460017",
"0.54169947",
"0.5402411",
"0.5358456",
"0.5353845",
"0.5325129",
"0.53091663",
"0.5261959",
"0.5250193",
"0.523959",
"0.52378243",
"0.52058744",
"0.51471525",
"0.51471... | 0.6771792 | 0 |
Finds and returns the smallest unused element from 0 to n. | def next_id(arr):
for x in range(len(arr) + 1):
if x not in arr:
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nth_smallest_element(input_list, n):\n\tif n <= 0:\n\t\traise Exception(\"Invalid argument\")\n\n\tdeduped_sorted_list = list(sorted(set(input_list)))\n\treturn deduped_sorted_list[n - 1]",
"def get_smallest_element(self, n=1):\n\t\tstack = [self]\n\t\tsmallest = None\n\t\tcount = 0\n\t\twhile count < n and ... | [
"0.72080666",
"0.70314085",
"0.6650083",
"0.65984404",
"0.64688796",
"0.6426433",
"0.6358506",
"0.63570064",
"0.63551736",
"0.63042235",
"0.6289911",
"0.6261654",
"0.6171056",
"0.61558825",
"0.60650325",
"0.6059295",
"0.6016449",
"0.5981935",
"0.59537464",
"0.5949816",
"0.594... | 0.0 | -1 |
Return the machine status, as defined in `Server.status_data()`. Requires read access. | def status(code=200):
return jsonify(server.status_data()), code | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_status(self):\n return self.read_register(259, 0, 3)",
"def getStatus(self):\n\n self.sendCommand(cmdBytes = b'\\xfe')\n statusList = self.readReply(inputEndpoint=self.epStatus,\n unpackingFormat=self.statusPackingFormat,\n ... | [
"0.75821817",
"0.74087423",
"0.7262589",
"0.72497797",
"0.7208214",
"0.71589094",
"0.71352714",
"0.7088371",
"0.7081893",
"0.7078567",
"0.7051613",
"0.7011308",
"0.6992414",
"0.69921654",
"0.69677454",
"0.6932528",
"0.6932527",
"0.6929364",
"0.69280344",
"0.69222456",
"0.6911... | 0.0 | -1 |
Returns the next action in the path chosen earlier (in registerInitialState). Return Directions.STOP if there is no further action to take. | def getAction(self, state):
if 'actionIndex' not in dir(self): self.actionIndex = 0
i = self.actionIndex
self.actionIndex += 1
if i < len(self.actions):
return self.actions[i]
else:
return Directions.STOP | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action(self):\n next_action = self.strategy.get_next_move(self)\n return next_action",
"def get_action(self, state):\n if self.globSeq == []:\n self.globSeq = self.graphSearch(state)\n if not(self.globSeq):\n return Directions.STOP\n return sel... | [
"0.72917974",
"0.70389724",
"0.70389724",
"0.69733477",
"0.6870712",
"0.6823267",
"0.6764109",
"0.6656355",
"0.65738255",
"0.65582967",
"0.6466158",
"0.6421366",
"0.6365749",
"0.636001",
"0.6213877",
"0.61840165",
"0.61811143",
"0.6180762",
"0.6158909",
"0.6149792",
"0.611905... | 0.70153034 | 5 |
Return a new array of given shape and type, filled with zeros. | def zeros(shape, ctx=None, dtype=None, stype=None, **kwargs):
if stype is None or stype == 'default':
return _zeros_ndarray(shape, ctx, dtype, **kwargs)
else:
return _zeros_sparse_ndarray(stype, shape, ctx, dtype, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zeros(shape, dtype=None):\r\n if not isinstance(shape, (list, tuple, TensorVariable)):\r\n shape = [shape]\r\n if dtype is None:\r\n dtype = config.floatX\r\n return alloc(numpy.array(0, dtype=dtype), *shape)",
"def zeros(shape, dtype=None):\n\n return full(shape, 0, dtype)",
"def... | [
"0.8132084",
"0.79774994",
"0.7806014",
"0.7804865",
"0.7555395",
"0.75531137",
"0.75531137",
"0.75450706",
"0.7493995",
"0.7481365",
"0.73668027",
"0.73498267",
"0.73498267",
"0.7321162",
"0.7316188",
"0.73155236",
"0.7279779",
"0.72638404",
"0.72082555",
"0.7204798",
"0.713... | 0.7639992 | 4 |
Returns a new array of given shape and type, without initializing entries. | def empty(shape, ctx=None, dtype=None, stype=None):
if stype is None or stype == 'default':
return _empty_ndarray(shape, ctx, dtype)
else:
return _empty_sparse_ndarray(stype, shape, ctx, dtype) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def empty(shape, dtype=None, order='C'):\n return ndarray.__new__(matrix, shape, dtype, order=order)",
"def empty(shape, dtype=numpy.float64, order='C'):\n\n if (not use_origin_backend()):\n if order not in ('C', 'c', None):\n checker_throw_value_error(\"empty\", \"order\", order, 'C')\n\... | [
"0.6719834",
"0.6454388",
"0.62059367",
"0.61502916",
"0.6148206",
"0.61432266",
"0.60802484",
"0.6027261",
"0.5993374",
"0.598559",
"0.59465975",
"0.5937943",
"0.5887122",
"0.58601445",
"0.58567154",
"0.5855918",
"0.58521485",
"0.58349085",
"0.57767516",
"0.5776116",
"0.5755... | 0.6731557 | 0 |
Computes the QR decomposition of a matrix. Factor the matrix a as qr, where q is orthonormal and r is uppertriangular. | def qr(a, mode="reduced"):
return QRFull(mode)(a) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def qr_decomposition(self):\n if self.m != self.n:\n raise NotImplementedError('QR decomposition not yet available ' +\n 'for non-square matrices')\n orig_basis = [vec.Vector.fromMatrixColumn(self, j)\n for j in range(self.m)]\n ... | [
"0.78373367",
"0.71434283",
"0.7103119",
"0.70709246",
"0.6754979",
"0.67185795",
"0.65997547",
"0.6596669",
"0.654969",
"0.6548519",
"0.6543868",
"0.6505561",
"0.6419069",
"0.64135516",
"0.63907015",
"0.6237312",
"0.6204373",
"0.61034983",
"0.6077926",
"0.60377324",
"0.60061... | 0.70407236 | 4 |
r"""Raise a square matrix, ``M``, to the (integer) power ``n``. This implementation uses exponentiation by squaring which is significantly faster than the naive implementation. The time complexity for exponentiation by squaring is | def matrix_power(M, n):
if n < 0:
M = pinv(M)
n = abs(n)
# Shortcuts when 0 < n <= 3
if n == 0:
return at.eye(M.shape[-2])
elif n == 1:
return M
elif n == 2:
return tm.dot(M, M)
elif n == 3:
return tm.dot(tm.dot(M, M), M)
result = z = None... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _power(self, a, n, m):\n res = 1\n while n != 0:\n if n % 2 != 0:\n res *= a\n res %= m\n n -= 1\n else:\n a *= a\n a %= m\n n //= 2\n return res",
"def _pow_(self, n):\n ... | [
"0.7324359",
"0.6994466",
"0.688606",
"0.6770768",
"0.67672056",
"0.67287374",
"0.6562684",
"0.6559036",
"0.65072244",
"0.65032387",
"0.65009516",
"0.64860487",
"0.6431551",
"0.63874245",
"0.6353842",
"0.6319853",
"0.6318266",
"0.6240905",
"0.62354445",
"0.617687",
"0.6163312... | 0.7684998 | 0 |
Return int representing number of User model state changes found in transaction. | def user_state_update(
self,
update_task: DatabaseTask,
session: Session,
ipfs_metadata,
blacklisted_cids,
user_factory_txs,
block_number,
block_timestamp,
block_hash,
) -> Tuple[int, Set]:
num_total_changes = 0
user_ids: Set[int] = set()
if not user_factory_txs:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trans_num(self):\n\t\treturn len(self.transactions)",
"def trans_num(self):\n\t\treturn len(self.transactions)",
"def trans_num(self):\n return len(self.transactions)",
"def unsaved_changes(self) -> int:\n return (\n abs(self._snapshot_index - self._last_save_snapshot)\n ... | [
"0.6988201",
"0.6988201",
"0.6903699",
"0.64198303",
"0.63206166",
"0.6203949",
"0.6162762",
"0.6143286",
"0.61164224",
"0.6096743",
"0.6076003",
"0.60643697",
"0.6055905",
"0.60403544",
"0.5994034",
"0.5971175",
"0.59317255",
"0.59227324",
"0.59190136",
"0.5913419",
"0.59125... | 0.0 | -1 |
Retrieves the normalized timestamp. | def _GetNormalizedTimestamp(self):
if self._normalized_timestamp is None:
if self._number_of_seconds is not None:
self._normalized_timestamp = (
decimal.Decimal(self._deciseconds) /
definitions.DECISECONDS_PER_SECOND)
self._normalized_timestamp += decimal.Decimal(self._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _GetNormalizedTimestamp(self):\n if self._normalized_timestamp is None:\n if (self._number_of_seconds is not None and\n self.fraction_of_second is not None):\n self._normalized_timestamp = (\n decimal.Decimal(self._number_of_seconds) + self.fraction_of_second)\n\n return s... | [
"0.8163219",
"0.81526613",
"0.8087778",
"0.7107699",
"0.7048998",
"0.7046271",
"0.69856256",
"0.69384164",
"0.6928798",
"0.69227886",
"0.6920317",
"0.6907221",
"0.6855104",
"0.6834434",
"0.6827448",
"0.68216074",
"0.68162423",
"0.6809892",
"0.6770422",
"0.67637455",
"0.676183... | 0.78769654 | 3 |
Copies the RFC2579 datetime to a date and time string. | def CopyToDateTimeString(self):
if self._number_of_seconds is None:
return None
return (f'{self._year:04d}-{self._month:02d}-{self._day_of_month:02d} '
f'{self._hours:02d}:{self._minutes:02d}:{self._seconds:02d}'
f'.{self._deciseconds:01d}') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_datetime(self, data):\r\n data = make_naive(data)\r\n if self.datetime_formatting == 'rfc-2822':\r\n return format_datetime(data)\r\n\r\n return data.isoformat()",
"def _rfc822_datetime(self, t=None):\n\n if t is None:\n t = datetime.utcnow()\n\n ... | [
"0.67275983",
"0.6695923",
"0.6570495",
"0.6565789",
"0.6399404",
"0.6334223",
"0.6276405",
"0.62224025",
"0.62159836",
"0.61995256",
"0.619647",
"0.617536",
"0.6167912",
"0.616259",
"0.6099004",
"0.60932136",
"0.6081595",
"0.6063091",
"0.6035128",
"0.60258853",
"0.5979532",
... | 0.639128 | 5 |
Return a sample from a random variate. | def randerr(size=1,func='normal',**kwargs):
kwargs.update(size=size)
funclower = func.lower()
if funclower in ['normal','gaussian','gauss']:
rvs = stats.norm.rvs
elif funclower in ['uniform']:
rvs = stats.uniform(-1,2).rvs
elif funclower in ['lorentzian','cauchy']:
rvs = stat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_sample(self):\n mu = self._get_mean()\n sample = self.random.normal(mu)\n return sample",
"def sample(self):\n # return [v.sample() for v in self.variables]\n return self.domain[gc.rand_state.choice(len(self.domain))]",
"def _get_sample(self):\n mu = self._get... | [
"0.74732286",
"0.73824406",
"0.7360074",
"0.72706866",
"0.7201482",
"0.7157491",
"0.7125936",
"0.7070458",
"0.6995438",
"0.69871664",
"0.69417167",
"0.691943",
"0.69034404",
"0.6845009",
"0.68344057",
"0.67346376",
"0.67301464",
"0.6720028",
"0.6699844",
"0.66531813",
"0.6651... | 0.0 | -1 |
Returns API instance for cloud provider. | def get_api(provider):
# TODO(b/167685797): Use thread-local.
if provider == storage_url.ProviderPrefix.GCS:
return gcs_api.GcsApi()
elif provider == storage_url.ProviderPrefix.S3:
return s3_api.S3Api()
raise ValueError('Provider API value must be "gs" or "s3".') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_api(self):\n return self.api",
"def api(self):\n if self._api is None:\n self._api = Api(self)\n return self._api",
"def api_conn(self):\n try:\n credentials = None\n if tuple(googleapiclient.__version__) < tuple(\"1.6.0\"):\n ... | [
"0.6938213",
"0.66804665",
"0.6465663",
"0.645735",
"0.645735",
"0.645735",
"0.645735",
"0.6449945",
"0.64465636",
"0.64265794",
"0.6422378",
"0.6416929",
"0.63810474",
"0.634576",
"0.6292377",
"0.62358004",
"0.6193966",
"0.6150923",
"0.61457396",
"0.61454266",
"0.6131071",
... | 0.69704527 | 0 |
Draw detected bounding boxes. | def vis_detections(color_image, depth_colormap, class_col, dets_col, thresh=0.5):
for cls_ind, class_name in enumerate(class_col):
dets = dets_col[cls_ind]
inds = np.where(dets[:, -1] >= thresh)[0]
if len(inds) == 0:
continue
for i in inds:
bbox = [int(e) f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_bounding_boxes(self, bounding_boxes, output):\n for i, bb in enumerate(bounding_boxes):\n\n if bb[2] > output.shape[1] or bb[3] > output.shape[0] or bb[0] < 0 or bb[1] < 0:\n continue\n cv2.rectangle(\n np.asarray(output), (bb[0], bb[1]), (bb[2], ... | [
"0.77598673",
"0.7638101",
"0.7510348",
"0.72977304",
"0.7150563",
"0.7103931",
"0.7101873",
"0.7083905",
"0.7020769",
"0.6993739",
"0.6974172",
"0.69637305",
"0.6859061",
"0.68521667",
"0.68319523",
"0.6830371",
"0.6809837",
"0.6805064",
"0.67750585",
"0.6774759",
"0.6742592... | 0.0 | -1 |
Find the quantile which corresponds to a given value, based on a rolling window | def quantile_inv(obj, window, min_periods=None):
return obj.rolling(window=window, min_periods=min_periods).apply(lambda x: stats.percentileofscore(x, x[-1])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quantile(obj, quantile, window, min_periods=None, interpolation='linear'):\n return obj.rolling(window=window, min_periods=min_periods).quantile(quantile, interpolation=interpolation)",
"def calc(self,newValue):\n idx=np.searchsorted(self.quantiles, newValue, side=\"left\")\n if idx>=self.n-... | [
"0.7717787",
"0.61630803",
"0.59890836",
"0.5905023",
"0.5796287",
"0.57600486",
"0.5695445",
"0.5688301",
"0.5684145",
"0.5641279",
"0.5595518",
"0.55840075",
"0.55814624",
"0.5574285",
"0.5565961",
"0.5564753",
"0.5556741",
"0.5551058",
"0.55195904",
"0.5509968",
"0.5484216... | 0.74475795 | 1 |
How many friends does _user_ have? | def number_of_friends(user):
user_id = user["id"]
friend_ids = friendships[user_id]
return len(friend_ids) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_friends(users):\n all_friends=[]\n for u_dict in users:\n for items in u_dict['friends']:\n all_friends.append(items)\n count = Counter()\n for frnd in all_friends:\n count[frnd]+=1\n return count",
"def count_friends(users):\n ###TODO-- Completed\n\n ... | [
"0.76322424",
"0.7539812",
"0.74160075",
"0.72380906",
"0.71189487",
"0.703479",
"0.6933848",
"0.68708676",
"0.65430224",
"0.64357305",
"0.6395951",
"0.62994045",
"0.6272538",
"0.6253553",
"0.6249366",
"0.6245729",
"0.6233796",
"0.6211341",
"0.6203296",
"0.61625165",
"0.61239... | 0.8672473 | 0 |
Destructor for the ``JLink`` instance. Closes the JLink connection if one exists. | def __del__(self):
# weakref callbacks are rather low level, and working out how to use
# them correctly requires a bit of head scratching. One must find
# somewhere to store the weakref till after the referent is dead, and
# without accidentally keeping the referent alive. Then one mu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __del__(self):\n if self.__database_connection:\n self.__database_connection.close()\n self.__database_connection = None\n\n if self.__lucene_connection:\n self.__lucene_connection.close()\n self.__lucene_connection = None",
"def close_connection(self... | [
"0.70151716",
"0.6929349",
"0.687491",
"0.6787984",
"0.6753865",
"0.67448676",
"0.6672462",
"0.66579664",
"0.6620929",
"0.660229",
"0.6511459",
"0.6494374",
"0.64813477",
"0.6461889",
"0.641958",
"0.640157",
"0.63782",
"0.6369384",
"0.63608706",
"0.6327888",
"0.6327543",
"0... | 0.0 | -1 |
Finalizer ("destructor") for the ``JLink`` instance. Stops the SWO if enabled and closes the JLink connection if one exists. Called when exiting the context manager or when this object is destructed (garbage collected). | def _finalize(self):
if self._initialized:
if self.connected():
if self.swo_enabled():
self.swo_stop()
if self.opened():
self.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy(self):\r\n self._protocol.destroy()\r\n\r\n self._protocol = None",
"def __del__(self):\n if self._close_on_exit:\n self.close()",
"def close(self):\n self._update_cond()\n pn_link_close(self._impl)",
"def __del__(self):\n self.close_connection... | [
"0.7009699",
"0.6834285",
"0.66978455",
"0.66726774",
"0.6637629",
"0.65925676",
"0.6588747",
"0.65618676",
"0.6524396",
"0.65225303",
"0.6515733",
"0.64915806",
"0.6450616",
"0.64314955",
"0.6426532",
"0.6417308",
"0.6406179",
"0.6402182",
"0.63948053",
"0.63896024",
"0.6379... | 0.6590026 | 6 |
Returns whether the DLL is open. | def opened(self):
return bool(self._dll.JLINKARM_IsOpen()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_open(self):\n opened = ctypes.c_bool()\n\n result = self._lib.NRFJPROG_is_dll_open(ctypes.byref(opened))\n if result != NrfjprogdllErr.SUCCESS:\n raise APIError(result)\n \n return opened.value",
"def IsOpen(self):\n return self._is_open",
"def is_ope... | [
"0.8668237",
"0.7349179",
"0.72719353",
"0.72139436",
"0.7168035",
"0.7164919",
"0.7164339",
"0.6957772",
"0.6935094",
"0.6889131",
"0.6811832",
"0.6811832",
"0.6801945",
"0.6798037",
"0.6733291",
"0.67018276",
"0.6690784",
"0.6680774",
"0.6678992",
"0.66655904",
"0.66569847"... | 0.7768863 | 1 |
Returns the number of emulators which are connected via USB to the host. | def num_connected_emulators(self):
return self._dll.JLINKARM_EMU_GetNumDevices() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_usb_devices_count(self):\n\t\treturn call_sdk_function('PrlVmCfg_GetUsbDevicesCount', self.handle)",
"def get_device_count():\n debug(\"MpOrLibUsb.get_device_count()\")\n num = MpOrLibUsb.__get_device_count_Mpusb()\n num = num + MpOrLibUsb.__get_device_count_Libusb()\n return ... | [
"0.75948143",
"0.7488303",
"0.7421823",
"0.7240447",
"0.712322",
"0.7011725",
"0.6707582",
"0.6692651",
"0.6673403",
"0.6633537",
"0.6535353",
"0.644166",
"0.63627905",
"0.63612276",
"0.63183844",
"0.63135296",
"0.61730975",
"0.61198235",
"0.6083296",
"0.6074928",
"0.6061014"... | 0.79808414 | 0 |
Returns the number of devices that are supported by the opened JLink DLL. | def num_supported_devices(self):
return int(self._dll.JLINKARM_DEVICE_GetInfo(-1, 0)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_number_devices(self):\n no_devices = c_int()\n self._dll.ShamrockGetNumberDevices(byref(no_devices))\n return no_devices.value",
"def get_count():\n _check_init()\n return _pypm.CountDevices()",
"def get_device_count():\n debug(\"MpOrLibUsb.get_device_count()\")\n ... | [
"0.8036905",
"0.74780697",
"0.73417294",
"0.7198005",
"0.7023647",
"0.7010175",
"0.6907719",
"0.6780509",
"0.6728959",
"0.66914535",
"0.6675222",
"0.6625763",
"0.6375574",
"0.6238672",
"0.621861",
"0.6217971",
"0.61899847",
"0.61450744",
"0.6122327",
"0.6098339",
"0.6085897",... | 0.8533519 | 0 |
Returns the device's version. | def version(self):
version = int(self._dll.JLINKARM_GetDLLVersion())
major = version / 10000
minor = (version / 100) % 100
rev = version % 100
rev = '' if rev == 0 else chr(rev + ord('a') - 1)
return '%d.%02d%s' % (major, minor, rev) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_version(self):\r\n return self._arm.get_version()",
"async def get_version(self):\n\n # Display info message\n log.info(\"get_version\")\n\n # By default empty string\n version = \"\"\n\n # Run get version on the device\n output = await self.send_command(s... | [
"0.82263726",
"0.8171299",
"0.80680877",
"0.78703",
"0.78276557",
"0.7793323",
"0.7788481",
"0.7726637",
"0.7725001",
"0.77039313",
"0.77039313",
"0.76895887",
"0.76895887",
"0.7688344",
"0.7668107",
"0.76536644",
"0.76510096",
"0.76383454",
"0.76312083",
"0.7631014",
"0.7627... | 0.0 | -1 |
Returns the DLL's compatible JLink firmware version. | def compatible_firmware_version(self):
identifier = self.firmware_version.split('compiled')[0]
buf_size = self.MAX_BUF_SIZE
buf = (ctypes.c_char * buf_size)()
res = self._dll.JLINKARM_GetEmbeddedFWString(identifier.encode(), buf, buf_size)
if res < 0:
raise errors.JLi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def firmware_version(self):\n buf = (ctypes.c_char * self.MAX_BUF_SIZE)()\n self._dll.JLINKARM_GetFirmwareString(buf, self.MAX_BUF_SIZE)\n return ctypes.string_at(buf).decode()",
"def firmware_version(self):\n return self._get_system_status()[\"firmware\"]",
"def version(self):\n ... | [
"0.81136453",
"0.7407501",
"0.7352537",
"0.73288053",
"0.7198567",
"0.7127076",
"0.7099566",
"0.69830626",
"0.6921074",
"0.69126314",
"0.687439",
"0.68079406",
"0.6804166",
"0.6751391",
"0.66990024",
"0.6666999",
"0.66542935",
"0.6648657",
"0.6644194",
"0.6637442",
"0.6600397... | 0.77596503 | 1 |
Returns the product name of the connected JLink. | def product_name(self):
buf = (ctypes.c_char * self.MAX_BUF_SIZE)()
self._dll.JLINKARM_EMU_GetProductName(buf, self.MAX_BUF_SIZE)
return ctypes.string_at(buf).decode() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product_name(self):\n return self._product_name",
"def product_name(self):\n return self._stub.List(self._message).product_name",
"def product(self):\n return self.__values['product_name']",
"def product_name(self) -> Optional[str]:\n return pulumi.get(self, \"product_name\")"... | [
"0.72924954",
"0.7274736",
"0.70811665",
"0.69281614",
"0.66689706",
"0.6582853",
"0.6564504",
"0.65499675",
"0.65312827",
"0.6528013",
"0.63338166",
"0.6318037",
"0.62749875",
"0.62446964",
"0.6211255",
"0.6199241",
"0.61873746",
"0.6156995",
"0.6150432",
"0.60853916",
"0.60... | 0.73690933 | 0 |
Returns the serial number of the connected JLink. | def serial_number(self):
return self._dll.JLINKARM_GetSN() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serial_num(self) -> int:\n return self._serial_num",
"def _serial_number(self):\n hops_config = self._configurations[TextualDevice.connection_hops]\n cfg_ux2adb = hops_config[UnixRemote.unix_remote][AdbRemote.adb_shell]\n serial_number = cfg_ux2adb[\"command_params\"][\"serial_num... | [
"0.74930537",
"0.7472519",
"0.7297177",
"0.72521365",
"0.7209481",
"0.71740746",
"0.7126016",
"0.7054488",
"0.7054488",
"0.6969124",
"0.6953128",
"0.6952548",
"0.68861836",
"0.6873921",
"0.68738985",
"0.68629664",
"0.6844236",
"0.6748973",
"0.6740233",
"0.6600878",
"0.6553017... | 0.7896385 | 0 |
Returns a string of the builtin licenses the JLink has. | def licenses(self):
buf_size = self.MAX_BUF_SIZE
buf = (ctypes.c_char * buf_size)()
res = self._dll.JLINK_GetAvailableLicense(buf, buf_size)
if res < 0:
raise errors.JLinkException(res)
return ctypes.string_at(buf).decode() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def custom_licenses(self):\n buf = (ctypes.c_char * self.MAX_BUF_SIZE)()\n result = self._dll.JLINK_EMU_GetLicenses(buf, self.MAX_BUF_SIZE)\n if result < 0:\n raise errors.JLinkException(result)\n return ctypes.string_at(buf).decode()",
"def licenses(self) -> Sequence[str]:... | [
"0.7823846",
"0.7631993",
"0.6969341",
"0.68796015",
"0.6644712",
"0.66071224",
"0.65296596",
"0.6483877",
"0.6422204",
"0.63812995",
"0.63121504",
"0.62354946",
"0.61277324",
"0.6099809",
"0.6060002",
"0.60524994",
"0.6048665",
"0.60459536",
"0.6032868",
"0.6027193",
"0.5985... | 0.77635115 | 1 |
Returns a string of the installed licenses the JLink has. | def custom_licenses(self):
buf = (ctypes.c_char * self.MAX_BUF_SIZE)()
result = self._dll.JLINK_EMU_GetLicenses(buf, self.MAX_BUF_SIZE)
if result < 0:
raise errors.JLinkException(result)
return ctypes.string_at(buf).decode() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def licenses(self):\n buf_size = self.MAX_BUF_SIZE\n buf = (ctypes.c_char * buf_size)()\n res = self._dll.JLINK_GetAvailableLicense(buf, buf_size)\n if res < 0:\n raise errors.JLinkException(res)\n return ctypes.string_at(buf).decode()",
"def licenses(self) -> Sequen... | [
"0.8306052",
"0.7703566",
"0.6928596",
"0.692542",
"0.65299475",
"0.6383517",
"0.63345724",
"0.63305396",
"0.62964326",
"0.62551224",
"0.61774635",
"0.61500096",
"0.61296695",
"0.6076609",
"0.6066867",
"0.6051764",
"0.60314894",
"0.6010827",
"0.59672576",
"0.58672863",
"0.586... | 0.7874683 | 1 |
Returns the current target interface of the JLink. | def tif(self):
return self._tif | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetCurrentInterface(self):\n return self.current_interface",
"def get_target_interface(self):\n if self.get_target_interface_cache is None:\n ifaces = self.interfaces\n\n controller_ifaces = []\n for iface in ifaces:\n if self.controllers[self.con... | [
"0.74000406",
"0.69656324",
"0.69513327",
"0.68279874",
"0.68279874",
"0.68279874",
"0.68279874",
"0.68279874",
"0.68279874",
"0.6808537",
"0.6808537",
"0.6808537",
"0.6808537",
"0.6808537",
"0.6808537",
"0.6808537",
"0.6808537",
"0.6808537",
"0.6808537",
"0.6808537",
"0.6808... | 0.0 | -1 |
Sets the source to be used for tracing. The ``source`` must be one of the ones provided by ``enums.JLinkTraceSource``. | def set_trace_source(self, source):
self._dll.JLINKARM_SelectTraceSource(source)
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_source(self, source_name):\n self.source = source_name",
"def set_source(self, source):\n self.data['source'] = source",
"def source(self, source: str):\n if source is None:\n raise ValueError(\"Invalid value for `source`, must not be `None`\") # noqa: E501\n\n s... | [
"0.7424912",
"0.7381461",
"0.7311171",
"0.7253388",
"0.68773925",
"0.6792636",
"0.6792636",
"0.6792636",
"0.6792636",
"0.6792636",
"0.6792636",
"0.6792636",
"0.6792282",
"0.67182785",
"0.67182785",
"0.66947204",
"0.66931814",
"0.6658792",
"0.66483253",
"0.6540488",
"0.6418507... | 0.8096896 | 0 |
Returns whether the CPU core was halted. | def halted(self):
result = int(self._dll.JLINKARM_IsHalted())
if result < 0:
raise errors.JLinkException(result)
return (result > 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_halted(self):\n is_halted = ctypes.c_bool()\n\n result = self._lib.NRFJPROG_is_halted(ctypes.byref(is_halted))\n if result != NrfjprogdllErr.SUCCESS:\n raise APIError(result)\n\n return is_halted.value",
"def halted(self) -> bool:\n raise NotImplementedError(\... | [
"0.731646",
"0.7074767",
"0.6659457",
"0.6351942",
"0.63516337",
"0.6337303",
"0.63280857",
"0.6253793",
"0.6239191",
"0.62254965",
"0.6181615",
"0.6158565",
"0.6153918",
"0.61407137",
"0.613136",
"0.6123029",
"0.6111543",
"0.6089472",
"0.60701245",
"0.60701245",
"0.60701245"... | 0.68827885 | 2 |
Returns the device family of the target CPU. | def device_family(self):
return self._dll.JLINKARM_GetDeviceFamily() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_device_family(self):\n family = ctypes.c_int()\n\n result = self._lib.NRFJPROG_read_device_family(ctypes.byref(family))\n if result != NrfjprogdllErr.SUCCESS:\n raise APIError(result)\n\n return DeviceFamily(family.value).name",
"def get_family(self):\n\n re... | [
"0.6909385",
"0.64434975",
"0.6229879",
"0.6129597",
"0.6112738",
"0.60420865",
"0.59965724",
"0.59965724",
"0.59965724",
"0.59877867",
"0.5918032",
"0.5864088",
"0.5853863",
"0.583038",
"0.583038",
"0.58042604",
"0.58042604",
"0.57857424",
"0.57783484",
"0.57301265",
"0.5730... | 0.716312 | 0 |
Gets all memory zones supported by the current target. Some targets support multiple memory zones. This function provides the ability to get a list of all the memory zones to facilate using the memory zone routing functions. | def memory_zones(self):
count = self.num_memory_zones()
if count == 0:
return list()
buf = (structs.JLinkMemoryZone * count)()
res = self._dll.JLINK_GetMemZones(buf, count)
if res < 0:
raise errors.JLinkException(res)
return list(buf) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_zones():\n cf = CloudFlare.CloudFlare(raw=True)\n page_number = 0\n total_pages = 1\n all_zones = []\n while page_number < total_pages:\n page_number += 1\n raw_results = cf.zones.get(params={'per_page':100, 'page':page_number})\n zones = raw_results['result']\n ... | [
"0.6585587",
"0.65258205",
"0.63066727",
"0.6225679",
"0.60217327",
"0.5960012",
"0.5951327",
"0.59063154",
"0.5888627",
"0.5866608",
"0.58184415",
"0.57988656",
"0.5772288",
"0.57269365",
"0.5702966",
"0.5702966",
"0.569103",
"0.5649603",
"0.5636322",
"0.56067634",
"0.560375... | 0.76450336 | 0 |
Returns the number of currently active breakpoints. | def num_active_breakpoints(self):
return self._dll.JLINKARM_GetNumBPs() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getNumActive(self):\n return self._get_active( )",
"def num_active_watchpoints(self):\n return self._dll.JLINKARM_GetNumWPs()",
"def number_of_launches(self):\n return self._number_of_launches",
"def num_launches(self):\n return len(self.launches)",
"def memory_breakpoints(s... | [
"0.68647236",
"0.6606399",
"0.65112054",
"0.6283962",
"0.62659574",
"0.6215089",
"0.6161328",
"0.6122804",
"0.61183375",
"0.60720783",
"0.5995464",
"0.5945322",
"0.5942329",
"0.5907465",
"0.58732694",
"0.5870776",
"0.5852851",
"0.5849535",
"0.5793954",
"0.5735826",
"0.5728418... | 0.80561495 | 0 |
Returns the number of currently active watchpoints. | def num_active_watchpoints(self):
return self._dll.JLINKARM_GetNumWPs() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getNumActive(self):\n return self._get_active( )",
"def num_available_watchpoints(self):\n return self._dll.JLINKARM_GetNumWPUnits()",
"def count_current():\n return current.count()",
"def numRunningTotal(self):\n activeRuns = sum(run is not None for run in self.__running + self.__cli... | [
"0.70356363",
"0.69373614",
"0.6885585",
"0.6530227",
"0.64867383",
"0.6481708",
"0.63767076",
"0.63373053",
"0.6336179",
"0.6310618",
"0.6266817",
"0.62354225",
"0.62295246",
"0.62138057",
"0.61786413",
"0.61730844",
"0.61463946",
"0.60659444",
"0.60367024",
"0.60361654",
"0... | 0.8069319 | 0 |
Clears the trace event specified by the given handle. | def strace_clear(self, handle):
data = ctypes.c_int(handle)
res = self._dll.JLINK_STRACE_Control(enums.JLinkStraceCommand.TRACE_EVENT_CLR, ctypes.byref(data))
if res < 0:
raise errors.JLinkException('Failed to clear STRACE event.')
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def cancel_listen_log(self, handle: str) -> None:\n self.logger.debug(\"Canceling listen_log for %s\", self.name)\n await self.AD.logging.cancel_log_callback(self.name, handle)",
"def clear(self):\n self.events[get_ident()][0].clear()",
"def watchpoint_clear(self, handle):\n r... | [
"0.5847377",
"0.5841807",
"0.5766414",
"0.5558014",
"0.5521317",
"0.5482951",
"0.542024",
"0.5380767",
"0.5358833",
"0.53535414",
"0.5263508",
"0.524865",
"0.52404356",
"0.52147174",
"0.5135786",
"0.51096904",
"0.5055153",
"0.50205714",
"0.5013537",
"0.49863973",
"0.49727026"... | 0.7246619 | 0 |
Returns whether or not SWO is enabled. | def swo_enabled(self):
return self._swo_enabled | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_spow_enabled() -> bool:\n\n return _SPOW_ENABLED",
"def sso_enabled(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"sso_enabled\")",
"def is_on(self):\n return self._program.get(\"enabled\") is True",
"def is_enabled(self):\n return self.sdk.is_enabled",
"d... | [
"0.79768133",
"0.71558595",
"0.71338975",
"0.69183356",
"0.6888833",
"0.6888833",
"0.6888833",
"0.6888833",
"0.6888833",
"0.6888833",
"0.6856378",
"0.6809233",
"0.67789936",
"0.67789936",
"0.67789936",
"0.67789936",
"0.67789936",
"0.67789936",
"0.67789936",
"0.67789936",
"0.6... | 0.872539 | 0 |
Enables SWO output on the target device. Configures the output protocol, the SWO output speed, and enables any ITM & stimulus ports. This is equivalent to calling ``.swo_start()``. | def swo_enable(self, cpu_speed, swo_speed=9600, port_mask=0x01):
if self.swo_enabled():
self.swo_stop()
res = self._dll.JLINKARM_SWO_EnableTarget(cpu_speed,
swo_speed,
enums.JLinkSWOInterface... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable_output(self):\n\n self.__rtcconfig = self.__helper.updatebyte(self.__rtcconfig, 7, 1)\n self.__rtcconfig = self.__helper.updatebyte(self.__rtcconfig, 4, 1)\n self.__bus.write_byte_data(\n self.__rtcaddress, self.CONTROL, self.__rtcconfig)\n return",
"def swo_star... | [
"0.63976353",
"0.63337696",
"0.5933786",
"0.58872557",
"0.58789283",
"0.58205724",
"0.5778575",
"0.5746097",
"0.5728807",
"0.57080215",
"0.57026577",
"0.5694266",
"0.56766576",
"0.5658336",
"0.5641077",
"0.56345475",
"0.5598635",
"0.5560024",
"0.55540895",
"0.55470467",
"0.55... | 0.68389094 | 0 |
[Init method used to create an Api Class for making api calls] | def __init__(self, base_url, client_id, client_secret, client_scope, api_json = None):
# type: (str, str, str, str, str) -> None
self.base_url = base_url
self.client_id = client_id
self.client_secret = client_secret
self.client_scope = client_scope
# If the user doesn't... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.api = Api(consumer_key=credentials[\"consumer_key\"],\n consumer_secret=credentials[\"consumer_secret\"],\n access_token_key=credentials[\"access_token_key\"],\n access_token_secret=credentials[\"access_token_secret... | [
"0.8332173",
"0.8107438",
"0.80506295",
"0.8048945",
"0.79582095",
"0.78818417",
"0.78173226",
"0.781485",
"0.7814437",
"0.77590585",
"0.775339",
"0.77218103",
"0.77134943",
"0.7671552",
"0.7656446",
"0.7640684",
"0.75828683",
"0.7570891",
"0.7547598",
"0.75290906",
"0.750584... | 0.7338808 | 33 |
Takes in a one dimensional array of weights and repeats them to match shape Shape is expected to have the channels as the final dimension. | def repeat_weights(weights, shape):
weights_extra = weights.unsqueeze(-1)
return weights_extra.expand(
weights.shape[0], shape[-1]).reshape(shape) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def asrepeats(self):\n w_int = np.floor(self.weights).astype(int)\n return np.repeat(self.data, w_int, axis=0)",
"def cycle_rgb_weights(weights, n):\n slices = [(c % 3, c % 3 + 1) for c in range(n)] # slice a:a+1 to keep dims\n new_weights = torch.cat([\n weights[:, a:b, :, :] for a, ... | [
"0.6672087",
"0.65662587",
"0.61086744",
"0.6061735",
"0.593376",
"0.5924741",
"0.5821838",
"0.5821838",
"0.5752013",
"0.5740862",
"0.57109016",
"0.57063967",
"0.56983244",
"0.5653005",
"0.56268436",
"0.55902416",
"0.5578135",
"0.55723166",
"0.55514884",
"0.5545613",
"0.55306... | 0.80602807 | 0 |
Saves an array as an image at the save_location using pillow | def save_array_as_image(array, save_location):
image = Image.fromarray(array)
image.save(save_location)
image.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_img(img: np.ndarray, path: str) -> None:\n\n img_obj = Image.fromarray(img)\n img_obj.save(path)",
"def save_array_as_image(arr, filename):\n arr = arr.copy().clip(0, 255).astype('uint8')\n im = Image.fromarray(arr)\n im.save(filename)",
"def save_npimg(array: np.ndarray, path: str) -> ... | [
"0.7332789",
"0.73029846",
"0.7209719",
"0.7165053",
"0.7107845",
"0.68785155",
"0.68467116",
"0.6779601",
"0.6759873",
"0.67471975",
"0.6730639",
"0.6710754",
"0.66934115",
"0.662847",
"0.66220987",
"0.66107297",
"0.66057",
"0.6593635",
"0.65773165",
"0.65741265",
"0.6570185... | 0.8270457 | 0 |
Rewrite `get_bboxes` of `GFLHead` for default backend. Rewrite this function to deploy model, transform network output for a batch into bbox predictions. | def gfl_head__get_bbox(ctx,
self,
cls_scores,
bbox_preds,
score_factors=None,
img_metas=None,
cfg=None,
rescale=False,
with_nms=True,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def im_detect_bbox(model, im, target_scale, target_max_size, boxes=None):\n\n inputs, im_scale = _get_blobs(im, boxes, target_scale, target_max_size)\n\n \n\n if cfg.DEDUP_BOXES > 0:\n v = np.array([1, 1e3, 1e6, 1e9, 1e12])\n hashes = np.round(inputs['rois'] * cfg.DEDUP_BOXES).dot(v)\n ... | [
"0.6367146",
"0.63244224",
"0.63055766",
"0.62705636",
"0.61812466",
"0.61450016",
"0.6081446",
"0.6073175",
"0.60689294",
"0.60434335",
"0.6026332",
"0.6024328",
"0.5992725",
"0.5925751",
"0.5912662",
"0.5903787",
"0.5903787",
"0.5890349",
"0.5886075",
"0.5878742",
"0.584486... | 0.6346811 | 1 |
Return thread if user is a recipient. | def test_user_is_recipient(self):
UserThread.objects.create(user=self.user, thread=self.thread)
self.assertEqual(
Thread.public.get_by_user(
thread_id=self.thread.pk, user=self.user),
self.thread
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_is_recipient(self):\n recipient = self.create_user()\n thread = self.create_thread(recipient=recipient)\n self.assertTrue(thread.first_message.visible_to_user(recipient))",
"def test_user_is_sender(self):\n sender = self.create_user()\n thread = self.create_thread... | [
"0.75965565",
"0.67605346",
"0.63787115",
"0.63627005",
"0.6216186",
"0.6161424",
"0.60673016",
"0.6064786",
"0.59087336",
"0.5839849",
"0.5759381",
"0.568783",
"0.5608954",
"0.55944204",
"0.55939007",
"0.55842644",
"0.5551689",
"0.55199635",
"0.5511284",
"0.5464091",
"0.5454... | 0.7548641 | 1 |
Raise ObjectDoesNotExist if user doesn't have access. | def test_user_does_not_have_access(self):
self.assertRaises(
ObjectDoesNotExist,
Thread.public.get_by_user,
**{'thread_id': self.thread.pk, 'user': self.user}
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_object_permission(self, request, view, user):\n return user == request.user or request.user.is_superuser",
"def test_not_logged_user_cannot_access(self):\n\n utils.test_not_logged_cannot_access(self, self.url)",
"def test_not_logged_user_cannot_access(self):\n\n utils.test_not_logg... | [
"0.64512146",
"0.63119334",
"0.63119334",
"0.63119334",
"0.63119334",
"0.6311788",
"0.62217945",
"0.61707735",
"0.6165318",
"0.6149082",
"0.6141078",
"0.6141058",
"0.6130155",
"0.6103009",
"0.60953027",
"0.6091384",
"0.6080652",
"0.6068873",
"0.6054344",
"0.6051795",
"0.60517... | 0.69305414 | 0 |
returns a normalized version of X where the mean value of each feature is 0 and the standard deviation is 1. This is often a good preprocessing step to do when working with learning algorithms. | def featureNormalize(X):
X_norm, mu, sigma = X,0,0
# ====================== YOUR CODE HERE ======================
# Instructions: First, for each feature dimension, compute the mean
# of the feature and subtract it from the dataset,
# storing the mean value in mu. Next, c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_features(X):\n std = X.std(axis=0)\n std = np.where(std == 0, 1, std) # to avoid division by zero\n x_normed = (X - X.mean(axis=0)) / std\n return x_normed",
"def feature_normalize(X):\n X_mean = np.mean(X, axis=0)\n X_std = np.std(X, axis=0)\n X_std[0, 0] = 1\n X_normalize... | [
"0.8660045",
"0.84428126",
"0.8317792",
"0.82743424",
"0.8112482",
"0.7913407",
"0.76978165",
"0.76978165",
"0.76791483",
"0.76587653",
"0.76496303",
"0.75858235",
"0.7574672",
"0.75739104",
"0.7536636",
"0.74333113",
"0.7418857",
"0.72757375",
"0.7270763",
"0.7205566",
"0.71... | 0.76297015 | 11 |
tf.Node > String > [tf.Variable]? > (tf.Op, tf.Op) Create an Adam optimiser operation, along with an operation for initialising only the variables used internally by the optimiser. | def default_adam_optimiser_with_initialiser(loss_node, name, variables=None):
optimiser = tf.train.AdamOptimizer(name=name + ".adam_optimiser")
return (
optimiser.minimize(loss_node, var_list=variables, name=name + ".minimise"),
tf.variables_initializer(optimiser.variables()),
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_adam_optimiser(loss_node, name, variables=None):\n return tf.train.AdamOptimizer(name=name + \".adam_optimiser\").minimize(\n loss_node, var_list=variables, name=name + \".minimise\"\n )",
"def create_Adam_op(loss, alpha, beta1, beta2, epsilon):\n\n optimizer = tf.train.AdamOptimizer(... | [
"0.7339279",
"0.7098565",
"0.68570757",
"0.6683464",
"0.6683464",
"0.6646473",
"0.65805656",
"0.62965107",
"0.62862504",
"0.61791027",
"0.6176915",
"0.61711526",
"0.61447394",
"0.61211",
"0.610805",
"0.610314",
"0.608412",
"0.6071762",
"0.6050657",
"0.59981775",
"0.5984885",
... | 0.7426982 | 0 |
LossNode > String > [tf.Variable]? > Optimiser Create an Adam optimiser with default learning parameters set to minimise the given loss node. | def default_adam_optimiser(loss_node, name, variables=None):
return tf.train.AdamOptimizer(name=name + ".adam_optimiser").minimize(
loss_node, var_list=variables, name=name + ".minimise"
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_adam_optimiser_with_initialiser(loss_node, name, variables=None):\n optimiser = tf.train.AdamOptimizer(name=name + \".adam_optimiser\")\n return (\n optimiser.minimize(loss_node, var_list=variables, name=name + \".minimise\"),\n tf.variables_initializer(optimiser.variables()),\n ... | [
"0.77614534",
"0.65809083",
"0.64527076",
"0.64447564",
"0.628383",
"0.627875",
"0.62308496",
"0.61939293",
"0.6152135",
"0.614899",
"0.60573304",
"0.6016081",
"0.6007274",
"0.5994265",
"0.5990766",
"0.590552",
"0.58883333",
"0.58883333",
"0.58530587",
"0.5850922",
"0.5848501... | 0.80250835 | 0 |
if getting a string, return pennies on the dollar, or strippeddown string | def de_string(i, isint=True):
if isinstance(i, (str, unicode)):
try:
if isint:
return int(i.replace(".", "").replace("$", "").strip())
else:
return float(i.replace("$", "").strip())
except ValueError:
return i.strip()
return i | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_dollars(input, **kwargs):\n while input.startswith('$'):\n input = input[1:]\n while input.endswith('$'):\n input = input[0:-1]\n return input",
"def _strip_currency(amount):\n if amount[0] == '$':\n amount = amount[1:]\n if amount.find(\".\") != -1:\n return... | [
"0.6857114",
"0.64056754",
"0.63071275",
"0.6249889",
"0.5957392",
"0.5881029",
"0.57987446",
"0.56835437",
"0.5664021",
"0.5550171",
"0.55480945",
"0.55463266",
"0.5540557",
"0.5522002",
"0.5508715",
"0.5503365",
"0.5463383",
"0.5450946",
"0.54354465",
"0.5419111",
"0.540591... | 0.60157084 | 4 |
Feed forward our observation (forward propagation) and get the value of the actions given that we're in some set of states denoted by the observation | def forward(self, observation):
# Apply relu activation and feed forward
observation = F.relu(self.fc1(observation))
actions = self.fc2(observation)
return actions | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, obs_variable, actions_variable):\n state_action = torch.cat((obs_variable, actions_variable), 1)\n q_val_variable = self.model(state_action)\n\n return q_val_variable",
"def forward(self, state):\n x = state\n feature = self.feature_layer(x)\n action_va... | [
"0.7010782",
"0.67776686",
"0.6724738",
"0.6628955",
"0.66276807",
"0.66244805",
"0.65987736",
"0.6567183",
"0.65112364",
"0.6508202",
"0.65061283",
"0.65017265",
"0.64783996",
"0.6467277",
"0.6464391",
"0.6432744",
"0.6400561",
"0.6390434",
"0.6366373",
"0.6351905",
"0.63382... | 0.6431425 | 16 |
This function stores memory transitions. It takes in the current state, the action taken, the reward received, and the resulting state. | def store_transition(self, state, action, reward, new_state):
# Compute index and store transition data
index = self.memory_counter % self.max_mem_size
self.memory[index, :] = np.hstack((state, [action, reward], new_state))
# Increment counter for next index
self.memory_co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store(self, state, action, reward, next_state, done):\n self.replay_memory.append((state, action, reward, next_state, done))",
"def _add_to_memory(self, state, action, next_state, reward, done):\n if len(self.memory) >= self.size_max_memory:\n self.memory.pop(0)\n self.memory ... | [
"0.78003925",
"0.7743828",
"0.7680608",
"0.7605921",
"0.74234176",
"0.7423264",
"0.7420604",
"0.7280403",
"0.7150004",
"0.7060317",
"0.70299804",
"0.70268667",
"0.70176506",
"0.69925076",
"0.69925076",
"0.69904715",
"0.69667745",
"0.6926161",
"0.6858057",
"0.6842293",
"0.6714... | 0.82133657 | 0 |
Return true if there is at least one graphpoint with a dsName equal to dpName. | def isDataPointGraphed(self, dpName):
from DataPointGraphPoint import DataPointGraphPoint
return any(isinstance(gp, DataPointGraphPoint) and gp.dpName == dpName
for gp in self.getGraphPoints(includeThresholds=False)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDataPointGraphPoints(self, dpName):\n from DataPointGraphPoint import DataPointGraphPoint\n return [gp for gp in self.graphPoints()\n if isinstance(gp, DataPointGraphPoint)\n and gp.dpName == dpName]",
"def exists(self, name):\n assert name, \"Must input ... | [
"0.6595093",
"0.6454463",
"0.6090387",
"0.6087896",
"0.607874",
"0.5942403",
"0.5921128",
"0.5857084",
"0.5807831",
"0.57941604",
"0.57728535",
"0.5758609",
"0.5742762",
"0.5714896",
"0.56621575",
"0.56566477",
"0.5627397",
"0.56004417",
"0.5542626",
"0.55242914",
"0.5519199"... | 0.80648524 | 0 |
Sets the learning rate to the initial LR divided by 5 at 60th, 120th and 160th epochs | def adjust_learning_rate(optimizer, i_iter):
lr = lr_poly(cfg.Lr, i_iter, cfg.NUM_STEPS, cfg.POWER)
#lr = lr_warm_up(Lr, i_iter, NUM_STEPS, POWER, UP, KEEP)
for param_lr in optimizer.param_groups:
param_lr['lr'] = lr
return lr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_lr(self):\n learning_rate = self.params.base_lr * (1 - float(self.epoch) / self.params.num_epoch) ** self.params.power\n for param_group in self.opt.param_groups:\n param_group['lr'] = learning_rate\n print('Change learning rate into %f' % (learning_rate))\n self.s... | [
"0.7851729",
"0.7771049",
"0.7768421",
"0.75833607",
"0.7561154",
"0.75322944",
"0.7503269",
"0.7494458",
"0.7488913",
"0.74887127",
"0.74767107",
"0.7437975",
"0.7413997",
"0.7398021",
"0.7382977",
"0.7349557",
"0.7335179",
"0.7331621",
"0.7325815",
"0.7320968",
"0.73129857"... | 0.0 | -1 |
Select the column from dataset DataFrame and specified in col_name as label | def select_dfcol_as_label(self, col_name, bin_class):
self.labels = self.df[col_name]
if bin_class is True:
print("not supported yet")
else:
self.label_dict = {label: idx for idx, label in enumerate(
np.unique(self.df[col_name]))}
self.inv_label_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_column(variable):\n return relevant_raw_data_df[variable].to_frame()",
"def label_select_column(self, select, column):\n \n # SQLite doesnt like selecting from a subquery where the column\n # names look like table.colname. so if column is in a \"selected from\"\n # subqu... | [
"0.71116245",
"0.6975817",
"0.67848754",
"0.6755907",
"0.6674073",
"0.6640554",
"0.66266197",
"0.6534864",
"0.6457352",
"0.6382403",
"0.6370733",
"0.62386644",
"0.6228517",
"0.6224601",
"0.6166545",
"0.61638635",
"0.6116705",
"0.6104086",
"0.607919",
"0.60582227",
"0.60575294... | 0.67795783 | 3 |
Split dataset in n_subset parts and create as many dataset objects containing samples of original dataset chosen randomly with replacement | def random_sampling(self, n_subset):
t = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
print("[INFO] {} - Random sampling with replacement ...".format(t))
subset_list = []
training_set = self
subset_size = math.ceil(training_set.n_samples / n_subset)
# create subsets
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subsampleData(self, count):\n size = 0\n for block in self.blocks: size += len(block[1])\n subset = numpy.random.permutation(size)[:count]\n subset.sort()\n\n pos = 0\n index = 0\n ret = Dataset()\n for block in self.blocks:\n while subset[index]<(pos+len(block[1])):\n loc =... | [
"0.73276055",
"0.7179101",
"0.7172126",
"0.7058606",
"0.6954144",
"0.69088185",
"0.6906458",
"0.6873635",
"0.68358445",
"0.6793397",
"0.67461157",
"0.6732814",
"0.67272097",
"0.6716224",
"0.6622986",
"0.66004455",
"0.6593303",
"0.6583319",
"0.65280646",
"0.6527357",
"0.651893... | 0.73997825 | 0 |
Create a tensorflow layer Returns | def create(self):
output = None
if self.output_bias is not None:
output_bias = tf.keras.initializers.Constant(self.output_bias)
else:
output_bias = None
kernel_init = None
if self.activation_name == 'relu' or self.activation_name == 'elu':
# K... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_layer(prev, n, activation):\n\n kernel_ini = tf.contrib.layers.variance_scaling_initializer(mode=\"FAN_AVG\")\n layer = tf.layers.Dense(units=n, activation=activation,\n kernel_initializer=kernel_ini, name='layer')\n\n return layer(prev)",
"def add_layer(inputs, in_... | [
"0.7084781",
"0.6995747",
"0.68748116",
"0.6861905",
"0.682327",
"0.6651122",
"0.6620249",
"0.6570826",
"0.65648794",
"0.65595657",
"0.6548422",
"0.6535935",
"0.65260965",
"0.65102136",
"0.6508955",
"0.6496199",
"0.6476136",
"0.6464349",
"0.64168966",
"0.63907206",
"0.6385728... | 0.7174275 | 0 |
Keep track of token indices. | def index_tree(tree, offset):
for idx, _ in enumerate(tree.leaves()):
tree_location = tree.leaf_treeposition(idx)
non_terminal = tree[tree_location[:-1]]
# non_terminal.append(idx)
non_terminal[0] = (non_terminal[0], idx+offset)
return tree | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _tokens_to_index(self,tokens):\n wids = []\n for tk in tokens:\n if tk in self.wtoi.keys():\n wids.append(self.wtoi[tk])\n else:\n wids.append(1) # <UNK>\n for _ in range(self.sentence_max_length - len(wids)):\n wids.append(0)... | [
"0.7355989",
"0.70700705",
"0.68557656",
"0.6582347",
"0.6553393",
"0.65030026",
"0.64334935",
"0.6419829",
"0.63889736",
"0.6381239",
"0.6324228",
"0.6306379",
"0.6181237",
"0.6153679",
"0.6147161",
"0.6081978",
"0.60737103",
"0.6031734",
"0.6025489",
"0.601966",
"0.60065824... | 0.0 | -1 |
Transforms bin_indices into group indices, skips empty bins | def bin_to_group_indices(bin_indices, mask):
assert len(bin_indices) == len(mask), "Different length"
bins_id = numpy.unique(bin_indices)
result = list()
for bin_id in bins_id:
result.append(numpy.where(mask & (bin_indices == bin_id))[0])
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def groupDigitized(arr, bins, edges='right'):\n edges = edges.lower()\n if edges.startswith('r'): right = True\n elif edges.startswith('l'): right = False\n else: RuntimeError(\"``edges`` must be 'right' or 'left'!\")\n\n # `numpy.digitize` always assumes `bins` are right-edges (in effect)\n shif... | [
"0.6790227",
"0.60028476",
"0.59623134",
"0.59570706",
"0.5907395",
"0.5899478",
"0.5867087",
"0.5864903",
"0.5864903",
"0.58454823",
"0.5812525",
"0.58035856",
"0.57689106",
"0.5740283",
"0.5694048",
"0.56503814",
"0.56228024",
"0.5616195",
"0.5608595",
"0.5593722",
"0.55829... | 0.81799394 | 0 |
Computes cumulative distribution function (CDF) by ordered weights, be sure that sum(ordered_weights) == 1 | def compute_cdf(ordered_weights):
return numpy.cumsum(ordered_weights) - 0.5 * ordered_weights | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cdf(weights):\r\n\treturn np.cumsum(weights) / sum(weights)",
"def build_cdf(self,\n label: str, \n weights : str = None) -> np.array :\n\n if not weights == None:\n table = self.sample.sort_values(label)\n w = table[weights].values\n return np.array([tab... | [
"0.7808867",
"0.6640013",
"0.6417415",
"0.64035153",
"0.63425964",
"0.6248766",
"0.6175385",
"0.6148169",
"0.6113682",
"0.61068696",
"0.6064439",
"0.5981427",
"0.5885678",
"0.587889",
"0.58629364",
"0.5734454",
"0.57086366",
"0.5649806",
"0.56232774",
"0.56004256",
"0.5599004... | 0.90470666 | 0 |
sum weight |x x_mean|^power | def weighted_deviation(a, weights, power=2.):
mean = numpy.average(a, weights=weights)
return numpy.average(numpy.abs(mean - a) ** power, weights=weights) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weighted_sum(self, inputs):\r\n weighted_sum = 0\r\n for i in range(self.num_inputs):\r\n weighted_sum += self.weights[i]*inputs[i]\r\n return weighted_sum",
"def mean(self):\n return self.sum / self.sum_weights",
"def weighted_mean(x, sample_weight=None):\n if sample_weight is None... | [
"0.6961444",
"0.67395484",
"0.67359936",
"0.6699103",
"0.658371",
"0.6554287",
"0.65318036",
"0.6461502",
"0.64557815",
"0.6414253",
"0.6407969",
"0.63851166",
"0.63240147",
"0.63123304",
"0.62184125",
"0.618818",
"0.6184783",
"0.6156386",
"0.61452264",
"0.6136528",
"0.613234... | 0.6044014 | 28 |
Calculates damage factor on size. If weapon size is greater than the target size, then only the area that falls within the target will the damage be applied. | def size_damage_factor(weapon_size, target_size):
if weapon_size <= target_size:
return damage
return (target_size ** 2) / (weapon_size ** 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def true_damage(damage, weapon_size, target_size, source_debuff, target_debuff):\n\n # source_debuffs: tracking disruption\n tracking_disrupt = 1 + source_debuff.get('active', {}).get(\n 'tracking_disruption', 0)\n # target_debuffs: target painter, web\n target_painter = 1 + target_debuff.get('a... | [
"0.6976738",
"0.614433",
"0.6112917",
"0.5962203",
"0.5929868",
"0.59076524",
"0.58056116",
"0.57666886",
"0.5642174",
"0.563287",
"0.5591096",
"0.5555944",
"0.55480963",
"0.55103374",
"0.54974663",
"0.5475105",
"0.540319",
"0.54011244",
"0.5390442",
"0.5346287",
"0.53433824"... | 0.87186164 | 0 |
Return the name of the sensor. | def name(self):
return f"{habitica.DOMAIN}_{self._name}_{self._sensor_name}" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n return self._sensor.name",
"def get_sensor_name(self):\n return self.data[1]",
"def name(self):\n return self.device.device_data[self.device_id]['name'] + \\\n f' {self._sensor_type}'",
"def name(self):\n return f\"{self._name} {SENSOR_TYPES[self.senso... | [
"0.91898125",
"0.91688734",
"0.8901384",
"0.8770892",
"0.8510443",
"0.8479362",
"0.84436846",
"0.8298963",
"0.81862175",
"0.8106185",
"0.8079505",
"0.80660695",
"0.76988834",
"0.76104885",
"0.7609674",
"0.75989187",
"0.75989187",
"0.75989187",
"0.75374687",
"0.75150275",
"0.7... | 0.8049362 | 12 |
getType(self) Return which type of actor this dna represents. | def getType(self):
if (self.type == 's'):
#suit type
type = "suit"
elif (self.type == 'b'):
#boss type
type = "boss"
else:
notify.error("Invalid DNA type: ", self.type)
return type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_type(self):\n return self.__animal_type",
"def getType(self,):\n\t\treturn self.type;",
"def getType(self):\n return self.type_",
"def getType(self):\n return self.tipo",
"def get_type(self):\n return self.type",
"def get_type(self):\n return self.type",
"def ... | [
"0.6910517",
"0.66695154",
"0.6614324",
"0.6612874",
"0.6590619",
"0.6590619",
"0.6584954",
"0.6531742",
"0.65230954",
"0.65230954",
"0.64523363",
"0.64400464",
"0.64396113",
"0.63819426",
"0.63387024",
"0.6311867",
"0.6297006",
"0.62708443",
"0.62708443",
"0.62708443",
"0.62... | 0.6902624 | 1 |
Get a list of the trainable variables of the model. | def get_trainable_vars(self):
return self.arch.variables | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trainable_variables(self):\n return [v for p in self.parameters for v in p.trainable_variables]\n # TODO: look for variables NOT in parameters too\n # so users can mix-n-match tf.Variables and pf.Parameters in modules",
"def get_trainable_vars(self):\n params = tf.get_collection(t... | [
"0.84106857",
"0.83313924",
"0.81297374",
"0.8062774",
"0.8009906",
"0.79164755",
"0.78840417",
"0.78840417",
"0.77977896",
"0.776468",
"0.764058",
"0.7587395",
"0.7582669",
"0.7574112",
"0.75313574",
"0.74282765",
"0.74051094",
"0.73525757",
"0.73479426",
"0.7243529",
"0.715... | 0.85341656 | 0 |
Returns if the word is in the trie. | def search(self, word: str) -> bool:
node = self.find(word)
return node and node.is_word | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_trie(self, trie, word):\n current_dict = trie\n for letter in word:\n if letter in current_dict:\n current_dict = current_dict[letter]\n else:\n return False\n else:\n if '_end_' in current_dict:\n return curr... | [
"0.838632",
"0.8150416",
"0.8123471",
"0.7856802",
"0.7830664",
"0.77935004",
"0.7792806",
"0.77642965",
"0.7753436",
"0.7747724",
"0.7711298",
"0.76816714",
"0.7677101",
"0.7664614",
"0.76506114",
"0.76338875",
"0.7628353",
"0.76114196",
"0.7577657",
"0.75695884",
"0.756079"... | 0.74830437 | 28 |
Return a new point that is twice the old. | def double(self):
if self == INFINITY:
return INFINITY
# X9.62 B.3:
l = ((3 * self.__x * self.__x + self.__a) * inverse_mod(2 * self.__y, self.__p)) % self.__p
x3 = (l * l - 2 * self.__x) % self.__p
y3 = (l * (self.__x - x3) - self.__y) % self.__p
return ECPoi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def double_point(p1, ec=default_ec, FE=Fq):\n x, y = p1.x, p1.y\n left = 3 * x * x\n left = left + ec.a\n s = left / (2 * y)\n new_x = s * s - x - x\n new_y = s * (x - new_x) - y\n return AffinePoint(new_x, new_y, False, ec)",
"def retreat_point(self) -> Point2:\n return self._retreat... | [
"0.61314666",
"0.59783435",
"0.5895904",
"0.58678436",
"0.58678436",
"0.57877463",
"0.5724592",
"0.5666498",
"0.56604123",
"0.55943537",
"0.5563196",
"0.55497",
"0.55385524",
"0.55383086",
"0.55383086",
"0.5525608",
"0.5501164",
"0.549951",
"0.5491453",
"0.5474937",
"0.546985... | 0.56892234 | 7 |
This method initialize each metric object @ In, inputDict, dict, dictionary containing initialization parameters @ Out, none | def initialize(self,inputDict):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(self, runInfo, inputs, initDict) :\n super().initialize(runInfo, inputs, initDict)\n for metricIn in self.assemblerDict['Metric']:\n self.metricsDict[metricIn[2]] = metricIn[3]",
"def init_metrics(self):\n\n self.metrics = {}\n\n self.metrics['train_loss'] = np.zeros(0)\n ... | [
"0.82911104",
"0.75114757",
"0.71064746",
"0.7009915",
"0.68746525",
"0.68383324",
"0.68123096",
"0.6762167",
"0.6748141",
"0.67178404",
"0.6662818",
"0.66391",
"0.65985054",
"0.6591558",
"0.65275997",
"0.6515109",
"0.6511732",
"0.65076417",
"0.65033007",
"0.648643",
"0.64581... | 0.7064249 | 3 |
Return the sources slug instead of the id. | def to_representation(self, obj):
data = super(AccountInfoSerializer, self).to_representation(obj)
if obj.pk is None:
source = mkt.LOGIN_SOURCE_LOOKUP[mkt.LOGIN_SOURCE_UNKNOWN]
elif obj.source in self.ALLOWED_SOURCES:
source = mkt.LOGIN_SOURCE_LOOKUP[obj.source]
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def source_id(self) -> str:\n return self._source_id",
"def source_id(self) -> str:\n return self._source_id",
"def source_id(self) -> Optional[str]:\n return pulumi.get(self, \"source_id\")",
"def get_canonical_slug(self):\n return self.get_object().slug",
"def source_identifie... | [
"0.64594555",
"0.64594555",
"0.64080256",
"0.63634866",
"0.6338882",
"0.6338882",
"0.6310398",
"0.6266359",
"0.621801",
"0.6207257",
"0.6205775",
"0.6200629",
"0.61520404",
"0.6078017",
"0.60490143",
"0.59617907",
"0.5901329",
"0.586367",
"0.583934",
"0.58195454",
"0.58195454... | 0.0 | -1 |
Map a point to bitvector corresponding to the bin that contains it. | def pt2bv(self, point: float, tol=0.0):
index = self.pt2index(point, tol)
return int2bv(index, self.num_bits) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pt2bv(self, point: float, nbits: int, tol=0.0):\n assert isinstance(nbits, int)\n\n if self.periodic:\n point = self._wrap(point)\n\n index = self.pt2index(point, nbits, alignleft=True)\n\n if self.periodic:\n index = bintogray(index)\n\n return int2bv(i... | [
"0.65505666",
"0.62339324",
"0.61689186",
"0.61579394",
"0.5941974",
"0.577782",
"0.57645077",
"0.5728357",
"0.57117677",
"0.5679318",
"0.56495726",
"0.5640364",
"0.5601922",
"0.55837655",
"0.5542495",
"0.5530292",
"0.55136764",
"0.55078244",
"0.5478354",
"0.54094404",
"0.540... | 0.62397605 | 1 |
`y = 1 / (1 + exp(x))` | def sigmoid(x):
return 1 / (1 + np.exp(-x)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply(cls, x):\n return 1.0 / (1.0 + np.exp(-x))",
"def true_y_exp(x):\n y = torch.exp(x)#torch.sigmoid(x * 5) * 2 #exp(x)\n return y",
"def exp(x):\n raise NotImplementedError",
"def activate(self,x):\n return 1 / (1 + np.exp(-x))",
"def y(x,xi):\n return np.exp(-xi)-np.e... | [
"0.7997834",
"0.7724845",
"0.7702413",
"0.7686887",
"0.75947547",
"0.7583827",
"0.7548484",
"0.75173676",
"0.75157094",
"0.750876",
"0.74851584",
"0.7484046",
"0.74639034",
"0.7461077",
"0.7455336",
"0.74522334",
"0.7447609",
"0.74427867",
"0.7434122",
"0.7428947",
"0.7407589... | 0.754051 | 11 |
Called when the user specifies an intent for this skill | def on_intent(intent_request, session):
print("on_intent requestId=" + intent_request['requestId'] +
", sessionId=" + session['sessionId'])
intent = intent_request['intent']
intent_name = intent_request['intent']['name']
if('access_token' not in session):
oauth_request(session)
p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_intent(intent_request, session):\n\n intent = intent_request['intent']\n intent_name = intent_request['intent']['name']\n\n # Dispatch to your skill's intent handlers\n\n if intent_name not in skillmap:\n intent_name = \"NullSkill\"\n\n if intent_name in skillmap:\n try:\n ... | [
"0.7143966",
"0.6956116",
"0.6949057",
"0.6905333",
"0.68928874",
"0.67641324",
"0.6754843",
"0.6722764",
"0.6720773",
"0.67161995",
"0.6699252",
"0.6691263",
"0.6670276",
"0.6645522",
"0.6642719",
"0.6638686",
"0.6607724",
"0.6594981",
"0.6575682",
"0.6570076",
"0.65620786",... | 0.6473436 | 33 |
Initialize the weights in detector. | def init_weights(self, pretrained=None):
super(SingleTwoStageDetector176PRW, self).init_weights(pretrained)
self.backbone.init_weights(pretrained=pretrained)
if self.with_neck:
if isinstance(self.neck, nn.Sequential):
for m in self.neck:
m.init_wei... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initialize_weights(self):\n pass",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)\n # Tie weights if needed\n self.tie_weights()",
"def in... | [
"0.8447639",
"0.8180315",
"0.80988675",
"0.8020772",
"0.7919424",
"0.786902",
"0.7741314",
"0.77346873",
"0.76798457",
"0.7664226",
"0.7656543",
"0.76477873",
"0.75892216",
"0.75275147",
"0.7513663",
"0.7504854",
"0.7503682",
"0.7497825",
"0.7497825",
"0.7497825",
"0.7478873"... | 0.72344816 | 43 |
calculates unix time {timestamp} unix time | def unixtime(self,current_datetime):
unixtime = time.mktime(current_datetime.timetuple())
return unixtime | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unix_timestamp():\n return int(time.time())",
"def to_unix_time(timestamp):\n date = datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S')\n return int(time.mktime(date.timetuple()))*1000",
"def timestamp_to_unix(timestamp):\n return timestamp / 1e6",
"def unix_to_timestamp(unix):\n return int... | [
"0.75879526",
"0.72743046",
"0.7240875",
"0.6981259",
"0.6971941",
"0.69171464",
"0.68840486",
"0.6867971",
"0.67354965",
"0.6705537",
"0.6673837",
"0.66143626",
"0.66042805",
"0.6556207",
"0.6547878",
"0.6538946",
"0.65306395",
"0.65190667",
"0.6467715",
"0.64343226",
"0.641... | 0.7110069 | 3 |
Return a reference configuration. | def get_config_template(self) -> cconfig.Config:
config = cconfig.get_config_from_nested_dict(
{
# Load prices.
self._get_nid("rets/read_data"): {
"frequency": "T",
"start_date": "2010-01-04 09:00:00",
"end_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config(self):\n if self.allow_reco():\n return self.chs_config()\n else:\n return self.get_config_j(self.id)",
"def config(self):\n return self._config",
"def config():\n return _config",
"def _get_config(self):\n return self.__config",
"def _get_config(... | [
"0.65092355",
"0.65013164",
"0.64974004",
"0.64919037",
"0.64919037",
"0.64919037",
"0.64919037",
"0.64919037",
"0.64919037",
"0.64919037",
"0.64919037",
"0.64919037",
"0.64919037",
"0.64919037",
"0.64919037",
"0.64919037",
"0.64919037",
"0.64919037",
"0.64919037",
"0.64919037"... | 0.0 | -1 |
Coalesce this whole slice into a single one. Brutally. | def coalesce(self) -> TemplatedFileSlice:
return TemplatedFileSlice(
PythonTemplater._coalesce_types(self.slice_buffer),
self.source_slice,
self.templated_slice,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concat_all(self):\n return self.merge(1)",
"def reduce(self):\n return self.crop(*self.ink_offsets)",
"def trim(self):\n for i in range(len(self)):\n if self[i] != TRIT_ZERO:\n return self.__class__(self[i:])\n return self.__class__([])",
"def coalesc... | [
"0.5401775",
"0.5277561",
"0.5086095",
"0.50274026",
"0.50246334",
"0.50178045",
"0.49937516",
"0.49930096",
"0.49813202",
"0.49351832",
"0.4933961",
"0.49174333",
"0.49125135",
"0.4882212",
"0.48642638",
"0.48623437",
"0.485516",
"0.48501262",
"0.48427582",
"0.48148936",
"0.... | 0.6366621 | 0 |
Filter a dict of occurrences to just those within a slice. | def _filter_occurrences(
file_slice: slice, occurrences: Dict[str, List[int]]
) -> Dict[str, List[int]]:
filtered = {
key: [
pos
for pos in occurrences[key]
if pos >= file_slice.start and pos < file_slice.stop
]
for ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _filter_dict(src_dict, key_set):\n for k in set(src_dict.keys()) - key_set:\n src_dict.pop(k)",
"def filter(self, dict):\n for (pos, hashKey) in enumerate(self._sequence):\n for (key, value) in dict.items():\n data = self.dictionary[hashKey]\n \n ... | [
"0.6243578",
"0.6126197",
"0.60437065",
"0.6037379",
"0.59448564",
"0.5802446",
"0.574578",
"0.5740564",
"0.562094",
"0.558148",
"0.5568815",
"0.55339736",
"0.54904217",
"0.5432098",
"0.54097915",
"0.5405255",
"0.54017603",
"0.5372058",
"0.5365594",
"0.5335989",
"0.53254646",... | 0.76616806 | 0 |
Generates a pretty(er) name from a database table name. | def get_name(tablename):
return tablename[tablename.find("_") + 1:].replace("_", " ").capitalize() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def standardize_table_name(self, schema_name: str, table: str) -> str:\n return table",
"def table_name() -> str:\n pass",
"def encodeTableName(self, schema, table):\r\n return '\"{}\".\"{}\"'.format(schema, table)",
"def rename_table(base, tablename: str, table: Table) -> str:\n retu... | [
"0.79033035",
"0.773714",
"0.73384494",
"0.71828234",
"0.71329236",
"0.6959852",
"0.6873793",
"0.679506",
"0.67729133",
"0.676234",
"0.6733919",
"0.6698664",
"0.6696577",
"0.6682367",
"0.6632467",
"0.6570783",
"0.6557303",
"0.6554159",
"0.6529655",
"0.6529655",
"0.6529655",
... | 0.75213325 | 2 |
A basic infix arithmetic parsing class Optimize [bool] Specifies whether to "optimize" the code. This mainly resolves constant integers. | def __init__(self, optimize: bool = True, sort: bool = True, tokens: dict[str, int] = basicTokens):
self.optimize = optimize
self.sort = sort
# Parentheses always need to be considered tokens
self.tokens = tokens | {"(":[0, None],")":[0, None]} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_operators(self, instr):\n # change ++, -- to add(1), sub(1)\n instr = re.sub(r\"\\+\\+\", \".add(1)\", instr)\n instr = re.sub(r\"--\", \".sub(1)\", instr)\n\n m1 = re.search(r\"[+\\-*/]=\", instr)\n result = \"\"\n if m1:\n # handle the string with ... | [
"0.5747159",
"0.5733757",
"0.56535786",
"0.5597894",
"0.5584964",
"0.5555246",
"0.55296665",
"0.5471911",
"0.5377449",
"0.5376744",
"0.5339946",
"0.53193134",
"0.53180784",
"0.53176147",
"0.53149587",
"0.5303363",
"0.5261037",
"0.52405995",
"0.5207025",
"0.5182001",
"0.517084... | 0.4640844 | 80 |
Converts infix algebra to postfix algebra. expr [str] The input expression | def infix_to_postfix(self, expr: str) -> str:
# The stack that we will be performing operations on
stack: list[str] = []
# The output
output: str = ""
# We always need surrounding parentheses
expr = f"({expr})"
# The tokenized expression
expr = self.to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def infix_to_postfix(expr):\n ops = Stack()\n postfix = []\n toks = expr.split()\n def tests(chr):\n if chr.isdigit():\n postfix.append(chr)\n\n elif chr == '(':\n ops.push('(')\n\n elif ops.peek() == '(' or ops.empty():\n ops.push(chr)\n\n e... | [
"0.80606633",
"0.7964601",
"0.75717115",
"0.7413668",
"0.7239577",
"0.72022945",
"0.71805865",
"0.7122943",
"0.71209925",
"0.70804083",
"0.6996111",
"0.6981953",
"0.6951314",
"0.6925259",
"0.68769896",
"0.6873741",
"0.6764516",
"0.66924584",
"0.6663781",
"0.6653798",
"0.66431... | 0.78375685 | 2 |
Converts infix algebra to prefix algebra. expr [str] The input expression | def infix_to_prefix(self, expr: str) -> str:
# Reverse expr
expr = reversed(expr)
# Convert expr to list
expr = list(expr)
# Reverse all parantheses
for i, e in enumerate(expr):
if e == "(":
expr[i] = ")"
elif e == ")":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_prefix_expression(cls, expression):\n\t\tlogger.info(f\"in the calculate prefix expression {expression}\")\n\t\telements = expression.split()\n\t\tstack = []\n\t\tfor e in reversed(elements):\n\t\t\tif e.isdigit():\n\t\t\t\tstack.append(int(e))\n\t\t\telse:\n\t\t\t\t# this is an operator\n\t\t\t\tif ... | [
"0.664578",
"0.6562387",
"0.6492114",
"0.6489635",
"0.64423674",
"0.64218444",
"0.6409474",
"0.6332373",
"0.6211638",
"0.614548",
"0.5933642",
"0.5890488",
"0.58857906",
"0.5869483",
"0.58240837",
"0.5795316",
"0.5790727",
"0.57855725",
"0.57208693",
"0.57087123",
"0.56760514... | 0.7931066 | 0 |
Test case for get_ban | def test_get_ban(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_ban(self):\n pass",
"def test_get_bans(self):\n pass",
"def test_update_ban(self):\n pass",
"async def test_ban(self, ctx):\n try:\n pass\n except Exception as e:\n await zb.bot_errors(ctx,sp.format(e))",
"def test_get_boat(self):\n ... | [
"0.7934899",
"0.7560778",
"0.75315344",
"0.7478688",
"0.7169812",
"0.66973203",
"0.6488742",
"0.628112",
"0.6273042",
"0.62508875",
"0.621656",
"0.6197768",
"0.6180028",
"0.6118127",
"0.6111247",
"0.61067003",
"0.6090702",
"0.60592026",
"0.6037157",
"0.6023306",
"0.59936166",... | 0.9343103 | 0 |
check if image is rgb only accept rgb image when building train set | def is_RGB(self,img_path):
image=Image.open(img_path)
image=np.asarray(image)
if(len(image.shape)<3):
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_rgb(im):\n if(im.ndim == 3):\n return True\n else:\n return False",
"def is_rgb(img: np.ndarray) -> bool:\n\n return len(img.shape) >= 1 and img.shape[-1] == 3",
"def rgb(self) -> bool:\n return self.image_shape[2] == 3",
"def needs_to_convert_to_RGB(ds: \"Dataset\") -> b... | [
"0.75897574",
"0.7488315",
"0.7052029",
"0.6925399",
"0.67762756",
"0.6470295",
"0.6423139",
"0.64042914",
"0.63852924",
"0.6360768",
"0.63093615",
"0.6304243",
"0.6286628",
"0.62787783",
"0.6255236",
"0.62297255",
"0.6175592",
"0.6144822",
"0.6069844",
"0.6052767",
"0.605276... | 0.7507989 | 1 |
Return regexp that matches if this regexp matches nonzero number of times. | def many(self):
return self.opt.NonZeroCount(self._trg) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile_regex(x, n_times=\"+\"):\n y = \"(\" + \"|\".join(x) + \")\" + n_times\n return y",
"def repeat(pattern, capture=True):\r\n return (r\"(\" if capture else r\"(?:\") + pattern + r\")+\"",
"def oneof(chars):\n return Pattern(\"[\" + re.escape(chars) + \"]\")",
"def test_match_left_r... | [
"0.59987944",
"0.5888315",
"0.5827049",
"0.58187586",
"0.58134586",
"0.5812111",
"0.56728774",
"0.56495696",
"0.56469375",
"0.56469375",
"0.5555703",
"0.5485504",
"0.5458883",
"0.54250723",
"0.5409904",
"0.5331216",
"0.5303408",
"0.5298016",
"0.524574",
"0.524451",
"0.5232507... | 0.0 | -1 |
Test for user registration if the username given email is invalid. | def test_registeration_invalid_email(self):
response = self.signup_a_user(self.user_invalid_email)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response.data["errors"]["email"],
["Enter a valid email address."]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_register_email():\n email = request.args.get('email')\n if not email:\n return jsonify({'valid': False, 'error': 'Please provide an email address'})\n user = User.query.filter_by(email=email).first()\n if user:\n # The email already exists\n return jsonify({'valid': Fa... | [
"0.7547907",
"0.74165046",
"0.73967505",
"0.732267",
"0.72933745",
"0.72748053",
"0.7253366",
"0.72475505",
"0.7102373",
"0.70894736",
"0.70877165",
"0.7083112",
"0.707519",
"0.707519",
"0.70706815",
"0.70548916",
"0.70492876",
"0.70419025",
"0.70329314",
"0.70305437",
"0.700... | 0.78273094 | 0 |
Test for user registration if the username entered already exists. | def test_registeration_duplicate_username(self):
self.signup_a_user(self.user_data)
response_duplicate = self.signup_a_user(
self.user_data_duplicate_username)
self.assertEqual(response_duplicate.status_code,
status.HTTP_400_BAD_REQUEST)
self.assertEq... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def username_exist_check(form, field):\n username = field.data\n user = UserModel.query(UserModel.username==username).get()\n if user:\n raise validators.ValidationError('username exists, choose a different one!')",
"def test_incorrect_user_registeration_duplicate_username(self):\n with se... | [
"0.7591259",
"0.7430318",
"0.7417273",
"0.74149245",
"0.7358232",
"0.7342233",
"0.7337628",
"0.72507143",
"0.72231424",
"0.72068596",
"0.7179421",
"0.7179032",
"0.7161134",
"0.71544224",
"0.71408266",
"0.7131557",
"0.710796",
"0.7104845",
"0.7086091",
"0.70827687",
"0.70806",... | 0.7743392 | 0 |
test if a password is valid | def test_invalid_password(self):
response = self.signup_a_user(self.password_lacks_specialchar)
self.assertEqual(response.data['errors']['password'],
["please consider a password that has a number, an "
"uppercase letter, lowercase letter and a special"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_password(self):\n pass_field = Field(\"\".join(['x' * (int(self.app.config['MAX_PWD_LEN']))]))\n\n valid_password(None, pass_field)",
"def test_check_password():\n assert check_password('Longpassword') == False\n assert check_password('123456') == False\n assert check_passwo... | [
"0.8705191",
"0.83413756",
"0.8287537",
"0.8198838",
"0.8192774",
"0.81880254",
"0.81536615",
"0.81281936",
"0.8101539",
"0.80953294",
"0.8084486",
"0.8037322",
"0.8026895",
"0.7993859",
"0.7971347",
"0.7969647",
"0.79630464",
"0.7938657",
"0.79173964",
"0.79091793",
"0.79054... | 0.732713 | 67 |
test if username is all digits | def test_username_nodigits(self):
response = self.signup_a_user(self.username_nodigits)
self.assertEqual(response.data['errors']['username'],
["username is invalid"]
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_valid_username(username):\n import string\n\n if not (len(username) > 2 and len(username) < 65):\n return False\n if not username[0] in string.letters:\n return False\n m = re_valid_username.match(username)\n return m.start() == 0 and m.end() == len(username)",
"def is_valid_u... | [
"0.749222",
"0.7390373",
"0.7346093",
"0.72677433",
"0.71696174",
"0.7146475",
"0.71124524",
"0.7102446",
"0.70952034",
"0.702313",
"0.698527",
"0.69834036",
"0.6970932",
"0.6950866",
"0.6871124",
"0.6868775",
"0.68443054",
"0.6786281",
"0.67423356",
"0.6703983",
"0.6701515",... | 0.0 | -1 |
Split the remote URI and filename | def get_remote_uri_and_filename(uri_to_filename: str) -> tuple:
wrld_wide_web = "www"
slashstr = "/"
begin_uri_ind = uri_to_filename.find(wrld_wide_web)
end_uri_ind = uri_to_filename[begin_uri_ind:].find(slashstr) + begin_uri_ind
if begin_uri_ind == -1:
end_uri_ind ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def urlunsplit(urlparts):\n res = urlparse.urlunsplit(urlparts)\n if os.name == 'nt' and urlparts[0] == 'file' and '|' not in urlparts[2]:\n # UNC paths must have 4 slashes: 'file:////server/path'\n # Depending on the path in urlparts[2], urlparse.urlunsplit()\n # left only two or three ... | [
"0.62937796",
"0.6218686",
"0.6200895",
"0.6087369",
"0.60476273",
"0.600817",
"0.6003365",
"0.59986997",
"0.59732485",
"0.5964299",
"0.59405315",
"0.5875241",
"0.58545583",
"0.5850874",
"0.58473027",
"0.583716",
"0.5829513",
"0.5802676",
"0.57771903",
"0.5771919",
"0.5765623... | 0.6659016 | 0 |
Function for removing stopwords from spanish and unique characters | def _remove_stopwords(self, doc: str):
processed_tweet = [word for word in doc.split() if
word not in stopwords.words('spanish') and
len(word) > 1]
return ' '.join(processed_tweet) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_stopwords(words):\n new_words = []\n for word in words:\n if word not in stopwords.words('spanish'):\n new_words.append(word)\n return new_words",
"def remove_stopwords_fun(self):\n tokens = str(self.doc).split()\n cleaned_tokens = [token for token in tokens\n ... | [
"0.78694767",
"0.78489774",
"0.78407156",
"0.77401924",
"0.7587487",
"0.7525981",
"0.7499562",
"0.7496318",
"0.74817586",
"0.74798423",
"0.74761623",
"0.7443526",
"0.7443526",
"0.7443526",
"0.7443526",
"0.7389394",
"0.7344267",
"0.73368216",
"0.73099554",
"0.7297928",
"0.7294... | 0.7678101 | 4 |
returns the ID of this network (property) | def id(self):
if self.cloudnet:
return self.cloudnet.id
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_network_id(self):\n\t\treturn call_sdk_function('PrlVirtNet_GetNetworkId', self.handle)",
"def network_id(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"network_id\")",
"def network_id(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"network_id\")",
"def network_id(self)... | [
"0.740598",
"0.7344751",
"0.7344751",
"0.7344751",
"0.7227023",
"0.71360755",
"0.70091057",
"0.68451583",
"0.68192357",
"0.67939615",
"0.67931455",
"0.67740667",
"0.6738172",
"0.67250645",
"0.67078197",
"0.67078197",
"0.66984546",
"0.6672266",
"0.66280186",
"0.6627441",
"0.66... | 0.7068746 | 6 |
Returns a gaussian function with the given parameters | def gaussian(height, center_x, center_y, width_x, width_y, rotation, height1, center_x1, center_y1, width_x1, width_y1, rotation1):
width_x = float(width_x)
width_y = float(width_y)
rotation = np.deg2rad(rotation)
center_x = center_x * np.cos(rotation) - center_y * np.sin(rotation)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussian(x, *parameters):\n position, sigma, amplitude, background = parameters\n return amplitude * np.exp(-(x - position)**2 / (2.0 * sigma**2)) + background",
"def gaussian(pars, x):\n A, b, mu, sigma = pars\n # return b + A/(np.sqrt(2*np.pi)*sigma**2) \\\n return b + A \\\n * np.exp... | [
"0.7934865",
"0.7810317",
"0.7587476",
"0.74887896",
"0.7464076",
"0.7385345",
"0.7374554",
"0.7266868",
"0.7266868",
"0.7266868",
"0.72426987",
"0.7226114",
"0.72215724",
"0.71309364",
"0.71272105",
"0.7118073",
"0.7088956",
"0.70818025",
"0.7071268",
"0.70585066",
"0.703256... | 0.6399046 | 78 |
Returns a gaussian function with the given parameters | def gaussian_norot(height, center_x, center_y, width_x, width_y, height1, center_x1, center_y1, width_x1, width_y1):
width_x = float(width_x)
width_y = float(width_y)
width_x1 = float(width_x1)
width_y1 = float(width_y1)
return lambda x,y: height*np.exp(
-(((cente... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussian(x, *parameters):\n position, sigma, amplitude, background = parameters\n return amplitude * np.exp(-(x - position)**2 / (2.0 * sigma**2)) + background",
"def gaussian(pars, x):\n A, b, mu, sigma = pars\n # return b + A/(np.sqrt(2*np.pi)*sigma**2) \\\n return b + A \\\n * np.exp... | [
"0.7936006",
"0.78110605",
"0.7589353",
"0.749031",
"0.74657845",
"0.7387422",
"0.73763347",
"0.7267818",
"0.7267818",
"0.7267818",
"0.7243705",
"0.7227015",
"0.72231114",
"0.713038",
"0.7127564",
"0.7118518",
"0.70896465",
"0.7083726",
"0.70708406",
"0.70604295",
"0.70323956... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.