query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Compress image array using SVD decomposition. | def svd_compress(imArr, K=50):
imArr_compressed = np.zeros(imArr.shape)
# For each channel
for ch in range(3):
# --------------------
# TODO:
# Compress the image array using SVD decomposition
# hint:
# 1. numpy.linalg.svd
# 2. numpy.diag
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Compress(Image, ComponentCount):\n u, s, vh = np.linalg.svd(Image)\n prev = len(s)\n u = u[:, 0:ComponentCount]\n s = s[0:ComponentCount]\n vh = vh.transpose()\n vh = vh.conjugate()\n vh = vh[:, 0:ComponentCount]\n compression_scale = prev / len(s)\n return u, s, vh, compression_scal... | [
"0.7247275",
"0.7078715",
"0.6578006",
"0.6345339",
"0.61687267",
"0.5876015",
"0.58707947",
"0.5862238",
"0.58569723",
"0.5771048",
"0.5768918",
"0.5745599",
"0.5735815",
"0.57188565",
"0.5627075",
"0.55328333",
"0.5497116",
"0.54893863",
"0.54740596",
"0.54589796",
"0.54289... | 0.8093388 | 0 |
Gets a new user agent string from the user_agent module, making sure that if one has already been selected, it's not reused. | def get_new_user_agent(self):
new_user_agent = user_agent.generate_navigator()["user_agent"]
if new_user_agent == self.user_agent:
self.get_new_user_agent()
return new_user_agent | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_agent(self):\n ua_list = [\n 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101',\n 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122',\n 'Mozilla/5.0 (Windows NT 6.1; WOW64... | [
"0.7215996",
"0.7215996",
"0.7149297",
"0.71108776",
"0.69777226",
"0.69335705",
"0.6727817",
"0.6658705",
"0.66479695",
"0.6638743",
"0.6604619",
"0.65992475",
"0.65622",
"0.6559405",
"0.65542805",
"0.6542164",
"0.6525318",
"0.65064514",
"0.6436991",
"0.63781244",
"0.636557"... | 0.7720028 | 0 |
Grabs the next proxy inline from the self.proxy_bag, and removes the currently used proxy. If proxy bag is empty, raises the EmptyProxyBag error. | def reset_proxy_from_bag(self):
if len(self.proxy_bag) == 0:
self.logger.debug("Changing proxy")
self.logger.warning("Proxy bag is empty! Cannot reset Proxy from Proxy Bag.")
raise errors.EmptyProxyBag
# Remove the current proxy from the proxy bag if one is set.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_proxy(self, proxied):\n\n val = self.proxy_map[proxied]\n\n try:\n del self.proxy_map[proxied]\n except KeyError:\n pass\n\n try:\n del self.proxy_map[val]\n del self.capability_map[val]\n except KeyError:\n pass",... | [
"0.6447425",
"0.56950754",
"0.56543666",
"0.5635704",
"0.5582781",
"0.5565788",
"0.55146444",
"0.5378243",
"0.53552455",
"0.53185356",
"0.5275862",
"0.5275862",
"0.51605374",
"0.5089712",
"0.5080257",
"0.50010437",
"0.49292418",
"0.48987725",
"0.48745558",
"0.4850618",
"0.484... | 0.7331339 | 0 |
Sets CarpetBag up to not force a valid certificate return from the server. This exists mostly because I was running into some issues with self signed certs. This can be enabled/disabled at anytime through execution. WARNING Would not typically recommend using "force=True", unless retrying a request is extremely taxing ... | def use_skip_ssl_verify(self, val=True, force=False):
if val:
self.ssl_verify = False
else:
self.ssl_verify = True
if force:
self.force_skip_ssl_verify = True
else:
self.force_skip_ssl_verify = False
return val | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def force_ssl_sync():\n return",
"def setIgnoreCertificateErrors(self, ignore: bool) -> Awaitable[Dict]:\n return self.client.send(\n \"Security.setIgnoreCertificateErrors\", {\"ignore\": ignore}\n )",
"def DisableSSLVerify():\n\n\t\ttry:\n\t\t\trequests.packages.urllib3.disable_war... | [
"0.59713656",
"0.56941324",
"0.5630117",
"0.5615266",
"0.55430776",
"0.5537122",
"0.54611325",
"0.54584414",
"0.53662133",
"0.536494",
"0.53507084",
"0.5298348",
"0.5288857",
"0.52458143",
"0.5203294",
"0.5150623",
"0.50940543",
"0.5081254",
"0.50494224",
"0.50409704",
"0.503... | 0.70022976 | 0 |
Runs a search query on a search engine with the current proxy, and returns a parsed result set. Currently only engine supported is duckduckgo. | def search(self, query, engine="duckduckgo"):
response = self.get("https://duckduckgo.com/html/?q=%s&ia=web" % query)
if not response.text:
return {}
parsed = self.parse(response)
results = parsed.duckduckgo_results()
ret = {
"response": response,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search(query):\n\n results = []\n url = _get_search_url(query)\n html = get_html(url)\n\n if html:\n soup = BeautifulSoup(html, \"html.parser\")\n divs = soup.findAll(\"div\", attrs={\"class\": \"web-result\"})\n\n for li in divs:\n res = DuckDuckGoResult()\n\n ... | [
"0.607996",
"0.5939284",
"0.5896712",
"0.5882372",
"0.588011",
"0.588011",
"0.5808758",
"0.5807896",
"0.5764619",
"0.576326",
"0.5741929",
"0.57398915",
"0.57386386",
"0.5690749",
"0.5687321",
"0.56545633",
"0.5652287",
"0.5622823",
"0.561794",
"0.5617934",
"0.5611579",
"0.... | 0.68244994 | 0 |
Checks the Tor Projects page "check.torproject.org" to see if we"re running through a tor proxy correctly, and exiting through an actual tor exit node. | def check_tor(self):
response = self.get("https://check.torproject.org")
parsed = self.parse(response)
title = parsed.get_title()
if title == "Sorry. You are not using Tor.":
self.logger.warning("Tor is NOT properly configured.")
return False
elif title ==... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_tor_connection():\n\n content = urlopen('https://check.torproject.org/').read()\n\n # <h1 class=\"off\"> - not using tor\n # <h1 class=\"not\"> - using tor without torbrowser\n # <h1 class=\"on\"> - using tor with torbrowser\n return content.find(b'class=\"off\"')==-1",
"def use_tor_... | [
"0.7698107",
"0.616715",
"0.595581",
"0.5895883",
"0.5787492",
"0.57005435",
"0.5672086",
"0.5658903",
"0.5653415",
"0.54754514",
"0.54626065",
"0.5460651",
"0.54536825",
"0.5420354",
"0.53994656",
"0.529183",
"0.5284102",
"0.52192754",
"0.5185694",
"0.51787347",
"0.5136729",... | 0.7982964 | 0 |
Gets the current outbound IP address for scrappy and sets the self.outbound_ip var. | def get_outbound_ip(self):
try:
response = self._make_internal("ip")
except errors.NoRemoteServicesConnection:
logging.error("Unable to connect to Bad-Actor.Services")
return False
self.outbound_ip = response.json()["ip"]
return self.outbound_ip | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDestinationIp(self):\n return self.destinationIp",
"def outbound_ips(self) -> Optional[pulumi.Input['ManagedClusterLoadBalancerProfileOutboundIPsArgs']]:\n return pulumi.get(self, \"outbound_ips\")",
"def effective_outbound_ips(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['Resource... | [
"0.65082407",
"0.6437389",
"0.6435474",
"0.6435474",
"0.6221881",
"0.6023555",
"0.5941486",
"0.5899906",
"0.588379",
"0.58644253",
"0.5857071",
"0.5842714",
"0.58216196",
"0.58026123",
"0.5798135",
"0.5795206",
"0.5723156",
"0.5683514",
"0.56315017",
"0.5624361",
"0.5616303",... | 0.79692715 | 0 |
Resets the User Agent String if using random user agent string (use_random_user_agent). Resets the proxy being used if (use_proxy_bag) and removes the current proxy from bag. | def reset_identity(self):
if self.random_user_agent:
self.user_agent = self.get_new_user_agent()
if self.random_proxy_bag:
self.reset_proxy_from_bag()
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_proxy_from_bag(self):\n if len(self.proxy_bag) == 0:\n self.logger.debug(\"Changing proxy\")\n self.logger.warning(\"Proxy bag is empty! Cannot reset Proxy from Proxy Bag.\")\n raise errors.EmptyProxyBag\n\n # Remove the current proxy from the proxy bag if o... | [
"0.6677113",
"0.6133902",
"0.60278416",
"0.5963965",
"0.5923906",
"0.58532196",
"0.5831108",
"0.5612078",
"0.5601302",
"0.54254353",
"0.53612053",
"0.5246809",
"0.51402813",
"0.51402813",
"0.5134337",
"0.5129917",
"0.5127677",
"0.508291",
"0.508291",
"0.5071725",
"0.5058938",... | 0.7169794 | 0 |
Tests the current public proxy to see if it is working. If it's not and the user is using proxy bag, we'll find a new one. | def test_public_proxy(self, retry_on_failure=True):
logging.info("Testing Proxy: %s (%s)" % (self.proxy_bag[0]["ip"], self.proxy_bag[0]["country"]))
self.use_skip_ssl_verify()
self.headers = {"Content-Type": "application/json"}
test_url = self.remote_service_api.replace("api", "test")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def proxy_check(self, proxy):",
"def use_random_public_proxy(self, val=True, test_proxy=False):\n if not val:\n self.random_proxy_bag = False\n return False\n self.random_proxy_bag = True\n\n if not self.proxy_bag:\n self.logger.debug(\"Proxy Bag already buil... | [
"0.7733405",
"0.7117575",
"0.7017398",
"0.6914103",
"0.67402637",
"0.66022635",
"0.65853786",
"0.65214443",
"0.64226997",
"0.6422141",
"0.6399249",
"0.63777775",
"0.62158525",
"0.6212572",
"0.61993545",
"0.6136303",
"0.61237454",
"0.6115175",
"0.6093141",
"0.60837007",
"0.607... | 0.7361702 | 1 |
Sets a header once for a request that returns successfully. | def set_header_once(self, key, value):
self.one_time_headers.append(key)
self.set_header(key, value)
return self.headers | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_header(response):\n response.headers['Authorization'] = response\n return response",
"def _setHeaders(self):\r\n if not self.headers_set:\r\n self.headers_set = 1\r\n for key in self.headers_out.keys():\r\n self._response.setHeader(key, self.headers_out[k... | [
"0.63230705",
"0.6204895",
"0.61476135",
"0.6105394",
"0.6088791",
"0.6088791",
"0.6083404",
"0.60628444",
"0.60241616",
"0.59696144",
"0.59696144",
"0.59665996",
"0.59639955",
"0.59607744",
"0.5958105",
"0.59537137",
"0.59483665",
"0.59483665",
"0.59483665",
"0.59483665",
"0... | 0.7179426 | 0 |
Sends usage stats to badactor.services, this helps rate the quality of proxy services so only the best proxies are selected. | def send_usage_stats(self, api_key, non_proxy_user_ip, val=True):
self.send_usage_stats_val = val
self.usage_stats_api_key = api_key
self.non_proxy_user_ip = non_proxy_user_ip
return val | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_usage_stats(self):\n self._usage.increment_usage_stats()",
"async def update_stats(self):\r\n\r\n\t\twhile True:\r\n\t\t\tlogging.info('Attempting to post server count')\r\n\t\t\ttry:\r\n\t\t\t\tawait self.dblpy.post_server_count()\r\n\t\t\t\tlogging.info(f'Posted server count ({len(self.bot.gu... | [
"0.6004013",
"0.5867979",
"0.5660525",
"0.5501437",
"0.5475802",
"0.5431179",
"0.5430048",
"0.53282905",
"0.5311055",
"0.5244435",
"0.51665664",
"0.5150761",
"0.51297927",
"0.51183045",
"0.51158965",
"0.50972825",
"0.50897354",
"0.50742394",
"0.50494194",
"0.50386304",
"0.501... | 0.6250957 | 0 |
removes any lines that are beyond the timeout. | def cull(self):
now = time.time()
self.lines = [line for line in self.lines if line.timestamp + self.timeout > now] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trim_timings(phrase_length, timings):\n extra_hits = np.argwhere(np.cumsum(timings) > int(phrase_length)).ravel()\n\n if len(extra_hits) != 0:\n all_to_end = np.min(extra_hits)\n del timings[all_to_end:]\n\n return timings",
"def _trunc_lines_append(self):\n\t\tp = self._edit.get_buffe... | [
"0.6349527",
"0.60249877",
"0.5973775",
"0.592355",
"0.580673",
"0.5727752",
"0.569577",
"0.56607836",
"0.5555222",
"0.5512689",
"0.5511025",
"0.5503078",
"0.54648167",
"0.54562956",
"0.5428875",
"0.54065245",
"0.5386878",
"0.5376456",
"0.5360201",
"0.5334302",
"0.5333658",
... | 0.7740447 | 0 |
If a line exists in the log that matches the line passed in, returns that line object, otherwise returns None. A line 'matches' if the text is the same, case insensitive and ignoring whitespace. | def getMatchingLine(self, line):
tokens = map(str.lower, line.text.split()) # easy way to ignore case and whitespace
for l in self.lines:
if map(str.lower, l.text.split()) == tokens:
return l # found a match
return None # no matches found | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_line(file: str, line: str, logfile: str) -> Union[str, bool]:\n current_file = read_file_log(file, logfile)\n m = re_search(rf\"{line}\", current_file)\n if m is not None:\n return m.group(0)\n return False",
"def match(line,keyword):\n line=line.lstrip()\n length=len(keyword)\n ... | [
"0.688188",
"0.673705",
"0.6683343",
"0.6666241",
"0.6652194",
"0.66231227",
"0.6491017",
"0.6437934",
"0.62715596",
"0.61238337",
"0.6111344",
"0.60473675",
"0.6031243",
"0.6031243",
"0.60291314",
"0.5985005",
"0.5979051",
"0.5962767",
"0.58837664",
"0.5826029",
"0.5768382",... | 0.7682697 | 0 |
adds a line to the log and culls any stale lines. | def add(self, line):
self.cull()
self.lines.append(line) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append_line_to_log(line = '\\n'):\n with open(logPath, 'a') as f:\n f.write(line + '\\n')",
"def append(self, line):\n self.buffer.append(line)",
"def append(self, line):\n self.ag.append(line)",
"def add(self, line):\n if self.unique is not False and self.unique is not Tru... | [
"0.6821657",
"0.63969713",
"0.6210151",
"0.616209",
"0.6158731",
"0.6155332",
"0.6132655",
"0.6109983",
"0.60988694",
"0.6074187",
"0.60716707",
"0.59934336",
"0.5985421",
"0.598461",
"0.5966128",
"0.5927086",
"0.5926362",
"0.59038687",
"0.58802426",
"0.586528",
"0.5864172",
... | 0.7312085 | 0 |
Adds support for localization in the logging. If ../nova/__init__.py exists, add ../ to Python search path, so that it will override what happens to be installed in /usr/(local/)lib/python... | def add_support_for_localization():
path = os.path.join(os.path.abspath(sys.argv[0]), os.pardir, os.pardir)
possible_topdir = os.path.normpath(path)
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
gettext.install('nova', unicode=1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def includeme(config):\r\n config.add_translation_dirs('faapp:locale', )\r\n config.add_subscriber('faapp.locale.add_renderer_globals', 'pyramid.events.BeforeRender')\r\n config.add_subscriber('faapp.locale.add_localizer', 'pyramid.events.NewRequest')",
"def includeme(config):\n\n import patches\n ... | [
"0.6291162",
"0.6224521",
"0.5834338",
"0.5764594",
"0.5700114",
"0.54782677",
"0.5361436",
"0.53607774",
"0.53573674",
"0.5319826",
"0.5305797",
"0.5224463",
"0.5187609",
"0.5176947",
"0.51709914",
"0.51578915",
"0.51368284",
"0.51174754",
"0.5070859",
"0.50612843",
"0.50524... | 0.8006806 | 0 |
Shuts down any services this program has started and shows results. | def _clean_up():
from tests.util import report
report.update()
if MAIN_RUNNER is not None:
MAIN_RUNNER.on_exit()
from tests.util.services import get_running_services
for service in get_running_services():
sys.stderr.write("Stopping service ")
for c in service.cmd:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop_services(self):\n logger.info(\"Stopping services: %s\", self.services)\n for service in self.services:\n with hide(*fab_quiet):\n sudo('service %s stop' % service)",
"def shutdown(self):\n\n self.log.debug(\"Shutting down %s application\" % self.app_name)\... | [
"0.6826566",
"0.66662294",
"0.62678224",
"0.6248803",
"0.620092",
"0.6148632",
"0.6085707",
"0.60548437",
"0.60259885",
"0.6015684",
"0.59887946",
"0.59693664",
"0.59467727",
"0.5922419",
"0.5919427",
"0.59193456",
"0.5896353",
"0.58475703",
"0.58460677",
"0.5821398",
"0.5817... | 0.71973765 | 0 |
Collect all the tensors representing numbers into a single one. A tensor is understood to represent a number when its name is ``"$number"`` or ``$i``. | def collect_numbers(operator):
new_tensors = []
number = 1
i_count = 0
is_complex = False
for tensor in operator.tensors:
if tensor.name == "$number":
if tensor.content.imag != 0:
is_complex = True
number *= tensor.content
elif tensor.name == "... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def t2n(*tensors):\n data_logger.info('t2n({}:{}{})'\n .format(type(tensors).__name__, len(tensors),\n tuple(type(t).__name__ for t in tensors)))\n if len(tensors) == 1:\n return list(map(np.array, (tensors[0],)))[0]\n return list(map(np.array, tensor... | [
"0.5830372",
"0.5825708",
"0.54742587",
"0.5431972",
"0.537556",
"0.52845967",
"0.527925",
"0.5261539",
"0.5225615",
"0.51534414",
"0.51292926",
"0.5127709",
"0.5120891",
"0.5111635",
"0.51107",
"0.5100971",
"0.50926346",
"0.50926244",
"0.50767297",
"0.5065638",
"0.50638473",... | 0.63753617 | 0 |
Remove all the Kroneker deltas, substituting them by the corresponding index contraction. | def remove_kdeltas(operator):
for pos, tensor in enumerate(operator.tensors):
if tensor.name == "kdelta":
new_op = OperatorSum([operator.remove_tensor(pos)])
n = new_op.operators[0].max_index + 1
new_op = Operator([generic(n, n)]).replace_first("generic", new_op)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _remove_from_index_operations(self, which, transforms):\n if len(transforms) == 0:\n transforms = which.properties()\n removed = np.empty((0,), dtype=int)\n for t in list(transforms):\n unconstrained = which.remove(t, self._raveled_index())\n removed = np.u... | [
"0.6080323",
"0.6080323",
"0.5911438",
"0.5832008",
"0.5655036",
"0.56547284",
"0.5560011",
"0.5421335",
"0.54032207",
"0.53621566",
"0.535159",
"0.5328359",
"0.53079796",
"0.52951676",
"0.5267197",
"0.52522033",
"0.52240103",
"0.52159065",
"0.5215549",
"0.52150494",
"0.52122... | 0.6371044 | 0 |
Replace the first occurrence of ``pattern`` by ``replacement`` in ``operator`` | def apply_rule(operator, pattern, replacement):
new_op = operator.match_first(pattern)
if new_op is None:
return None
return new_op.replace_first("generic", replacement) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def regexp_replace(\n self, pattern: Any, replacement: Any, flags: Optional[str] = None\n ) -> ColumnOperators:\n return self.operate(\n regexp_replace_op,\n pattern,\n replacement=replacement,\n flags=flags,\n )",
"def replacement(cls, search_p... | [
"0.68356377",
"0.66041344",
"0.65621614",
"0.60166216",
"0.5761901",
"0.55495423",
"0.55282766",
"0.55010945",
"0.54934835",
"0.5492451",
"0.540084",
"0.53719664",
"0.53543186",
"0.5350739",
"0.53375554",
"0.5324137",
"0.5298707",
"0.5288058",
"0.52557033",
"0.5247027",
"0.52... | 0.7630286 | 0 |
Apply all the given rules to the operator sum. With the adecuate set of rules this function can be used to express an effective lagrangian in a specific basis of operators | def apply_rules(op_sum, rules, max_iterations, verbose=True):
for i in range(0, max_iterations):
if verbose:
sys.stdout.write(
"\rApplying rules (iteration " +
str(i + 1) + "/" + str(max_iterations) + ")")
sys.stdout.flush()
op_sum = app... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_rules(term: Term, rules):\n return functools.reduce(apply_rule, rules, term)",
"def update_acc_by_rules(self) -> None:\n for rule, coeff in self.rules.items():\n acc_delta = rule(self) # can't call self.rule\n self.update_acc(acc_delta, coeff)",
"def append_rules(self... | [
"0.64918065",
"0.5928121",
"0.5580742",
"0.55390596",
"0.5489015",
"0.5442223",
"0.5433671",
"0.53886807",
"0.53367096",
"0.52972984",
"0.52956265",
"0.5274054",
"0.52662563",
"0.52547824",
"0.52512914",
"0.52508175",
"0.5250347",
"0.52071154",
"0.51887256",
"0.51873267",
"0.... | 0.7162076 | 0 |
Collect operators that are equal except for a numeric coefficient and sum the numbers to get one. | def sum_numbers(op_sum):
collection = []
for op in op_sum.operators:
# Strip numeric coefficient off
collected = False
num = 1
n_removed = 0
op = collect_numbers(op)
if op.tensors[0].name == "$number":
num = op.tensors[0].content
new_op = O... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collect_numbers_and_powers(op_sum):\n return OperatorSum([collect_numbers(collect_powers(op))\n for op in op_sum.operators])",
"def collect_numbers(operator):\n new_tensors = []\n number = 1\n i_count = 0\n is_complex = False\n for tensor in operator.tensors:\n ... | [
"0.6688382",
"0.6188537",
"0.596569",
"0.59612995",
"0.5951762",
"0.5869833",
"0.5806779",
"0.56662303",
"0.55770713",
"0.5569512",
"0.5558289",
"0.5472565",
"0.5470783",
"0.5468581",
"0.54612523",
"0.5448771",
"0.5426006",
"0.5417521",
"0.5396",
"0.5377994",
"0.53439593",
... | 0.74173737 | 0 |
given a kaltura video object, set the status on the media entry and update the server See KalturaClient.Core.KalturaEntryModerationStatus for enum definitions | def setModerationStatus(self, status):
kSetStatus(self, status) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multizone_new_media_status(self, group_uuid, media_status):\n _LOGGER.debug(\n \"[%s %s] Multizone %s media status: %s\",\n self.entity_id,\n self._cast_info.friendly_name,\n group_uuid,\n media_status,\n )\n self.mz_media_status[group... | [
"0.5763984",
"0.56661105",
"0.5640002",
"0.5603017",
"0.5533586",
"0.5530165",
"0.5488287",
"0.5436343",
"0.54348207",
"0.542494",
"0.542494",
"0.5409558",
"0.5373215",
"0.53122604",
"0.5302755",
"0.52939594",
"0.5281037",
"0.5257494",
"0.52451044",
"0.52404845",
"0.5238186",... | 0.57743543 | 0 |
saves the data to the corresponding Person and User objects This method also removes the image saved in the tmp directory and if a new avatar has been uploaded then the old avatar image is deleted. | def save(self, *args, **kwargs):
c_d = self.cleaned_data
if c_d.get('id') and c_d.get('avatar') and (
isinstance(c_d.get('avatar'), UploadedFile)):
person = get_object_or_404(Person, id=c_d.get('id'))
try:
old_avatar = person.avatar.file.name
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_avatar(self, _objectdata):\n\n #ToDo: should there be a separate Avatar() class?\n\n # if the object data pertains to us, update our data!\n if str(_objectdata.FullID) == str(self.agent.agent_id) or \\\n _objectdata.LocalID == self.agent.local_id:\n if _objec... | [
"0.6112822",
"0.6094898",
"0.5866212",
"0.58051175",
"0.5752679",
"0.57102644",
"0.5576271",
"0.5566373",
"0.5552704",
"0.55019814",
"0.54939103",
"0.5479418",
"0.5461823",
"0.5397815",
"0.53944284",
"0.5382238",
"0.53782207",
"0.5372016",
"0.5361807",
"0.5339948",
"0.5308686... | 0.6435948 | 0 |
A null (undefined) instance of `GXDMPPLY ` | def null(cls):
return GXDMPPLY() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def null(cls):\n return GXMXD()",
"def create(cls):\n ret_val = gxapi_cy.WrapDMPPLY._create(GXContext._get_tls_geo())\n return GXDMPPLY(ret_val)",
"def nulltest():",
"def X(self):\n return None if self.pX is None else self.pX.buf",
"def __none_left_mult(x, y):\n if x is not N... | [
"0.691417",
"0.5743294",
"0.5559749",
"0.5559652",
"0.5553827",
"0.5520381",
"0.5518753",
"0.5415572",
"0.5325077",
"0.5266724",
"0.52546644",
"0.52026594",
"0.51994437",
"0.51707566",
"0.51635",
"0.5159187",
"0.5159187",
"0.5145673",
"0.51355654",
"0.5121073",
"0.51063466",
... | 0.8087481 | 0 |
Creates a `GXDMPPLY ` object. | def create(cls):
ret_val = gxapi_cy.WrapDMPPLY._create(GXContext._get_tls_geo())
return GXDMPPLY(ret_val) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def null(cls):\n return GXDMPPLY()",
"def to_PDG(self):\n new = copy.copy(self)\n new._translator = CompiledFlux.pdg_to_corsika\n return new",
"def gxpg(self):\n\n if self._pg is None:\n self._pg = self.gxvox.create_pg()\n return self._pg",
"def null(cls):... | [
"0.53824943",
"0.5201605",
"0.5014627",
"0.49037677",
"0.48606914",
"0.48266637",
"0.47851714",
"0.46996048",
"0.46991435",
"0.4689435",
"0.46888694",
"0.46641594",
"0.4653608",
"0.46237206",
"0.46145096",
"0.46035844",
"0.4571648",
"0.45689788",
"0.45656684",
"0.45648736",
"... | 0.8254729 | 0 |
Moves a vertex and any associated lines. | def move_vertex(self, p, v, x, y, z):
self._move_vertex(p, v, x, y, z) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_vertices(self, vertices, code):\n for vertex in vertices:\n self.move_vertice(vertex, code)",
"def move_vertex(region, vertex, new_vertex, vert_dict):\n # Skip useless moves\n if vertex == new_vertex:\n return\n # Update the original region\n new_vertex_list = [new_v... | [
"0.6833393",
"0.66738605",
"0.6340052",
"0.5827739",
"0.5708329",
"0.5676819",
"0.56136113",
"0.55963665",
"0.5486447",
"0.542023",
"0.5396874",
"0.53677726",
"0.53545994",
"0.53276026",
"0.5312396",
"0.52726305",
"0.52651775",
"0.5254889",
"0.5253261",
"0.52463394",
"0.52429... | 0.7407235 | 0 |
Set a specific polygon into a `GXDMPPLY ` object. | def set_poly(self, p, vv_x, vv_y, vv_z):
self._set_poly(p, vv_x, vv_y, vv_z) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def PolygonPatch(polygon, **kwargs):\n return PathPatch(PolygonPath(polygon), **kwargs)",
"def set_geo(self, lon=None, lat=None):\n changed = False\n if not lon:\n lon = self.lon\n if not lat:\n lat = self.lat\n\n if not self.point and lon and lat:\n ... | [
"0.577355",
"0.56017464",
"0.5550407",
"0.5432882",
"0.54083717",
"0.54041576",
"0.53988194",
"0.5366352",
"0.5344979",
"0.5342881",
"0.5331345",
"0.5315115",
"0.5304908",
"0.53024393",
"0.529416",
"0.5247422",
"0.5247422",
"0.5217033",
"0.5207257",
"0.52057105",
"0.5195183",... | 0.5893092 | 0 |
Loads all the tables and columns indicated in the 'table_properties.json' file. | def load_db_tables(self):
self.list_of_tables = pd.read_json(os.path.join(self.config_path, self.db_config_file),
orient='records')[self.report_type]['table']
# Loading tables from database
for aux_index, table in enumerate(self.list_of_tables):... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_tables():\n inf(\"Loading tables\")\n \n m_url = 'https://s3-us-west-2.amazonaws.com/boliek-public/animals/'\n \n pinners = Table('pinners', metadata, autoload=True)\n i = pinners.insert()\n i.execute({'name': 'Mary', 'email': 'mary@example.com'},\n {'name': 'John', 'emai... | [
"0.638267",
"0.6109927",
"0.60784876",
"0.60767394",
"0.59831834",
"0.5930532",
"0.592881",
"0.5912661",
"0.5858813",
"0.58003217",
"0.5800225",
"0.5783026",
"0.5745354",
"0.5733871",
"0.5620355",
"0.5606268",
"0.5604591",
"0.5598335",
"0.55940664",
"0.55940664",
"0.55940664"... | 0.6360058 | 1 |
Replicates the tree's hierarchical merge structure using pandas DataFrames. Tree nodes represent database tables. Tree branches represent database joints. Merges are executed bottomup from the tree | def _recursive_merge(self, tree: Tree):
# Keep record of the parent subtree
parent = tree
# Visit all child nodes:
# 1) If child node is a leaf node, then merge parent node with child node
# 2) If child node is a root node, then:
# 2.1) Merge recursive... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(self):\n collapsable = self.findSameSubtrees()\n\n dummy = GraphiusNode(-1, None)\n for i, node in self.nodes.items():\n dummy.addNeighbor(node)\n\n # Perform the merge\n self.mergeHelper(dummy, collapsable)\n\n # Regenerate trees\n newNodes = s... | [
"0.6471755",
"0.6253537",
"0.61979556",
"0.59609455",
"0.58390087",
"0.5759789",
"0.5619037",
"0.5617006",
"0.5607947",
"0.55914813",
"0.5580155",
"0.55757487",
"0.5564688",
"0.5492073",
"0.5438949",
"0.54049015",
"0.5393453",
"0.5378428",
"0.5347989",
"0.53187037",
"0.531251... | 0.6259005 | 1 |
Force process amqp events, such as heartbeat packages. | def process_amqp_events(self):
self.connection.process_data_events() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def heartbeat_event(self, event):\r\n while not self.imm_jobs.empty():\r\n imm_job = self.imm_jobs.get_nowait()\r\n imm_job(self)\r\n \r\n if self.do_reconfigure:\r\n self.selmgr.reconfigure(self.current_consensus())\r\n self.do_reconfigure = False\r\n \r\n if self.run_all_jobs:\... | [
"0.57334954",
"0.56041074",
"0.56010824",
"0.55979455",
"0.5568188",
"0.55039835",
"0.5465826",
"0.5444292",
"0.5444292",
"0.5444292",
"0.5439717",
"0.5411059",
"0.5408663",
"0.54069597",
"0.53820825",
"0.53328305",
"0.53275687",
"0.5296802",
"0.52871495",
"0.526257",
"0.5261... | 0.7338269 | 0 |
Create a new exchange. | def create_exchange(self, exchange_name, exchange_type, internal=None):
self._channel.exchange_declare(
exchange=exchange_name,
durable=True, # Survive reboot
passive=False, # Perform a declare or just to see if it exists
internal=internal, # Can only be publis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_exchange(self, exchangename, public_key, private_key, user_id, uid = None, pw = None):\n if not exchangename or not public_key or not private_key:\n raise Exception(\"Exchangename, public key and private key must be given\")\n else:\n return self.exch_repo.create(exch... | [
"0.7370517",
"0.6457336",
"0.643226",
"0.6169629",
"0.61339194",
"0.6089777",
"0.59855735",
"0.59621066",
"0.59481925",
"0.5879927",
"0.58365184",
"0.57017606",
"0.5689928",
"0.5689928",
"0.5655385",
"0.55897355",
"0.55276364",
"0.55152327",
"0.5488463",
"0.53955394",
"0.5384... | 0.7666469 | 0 |
Check if a queue exists, given its name. | def queue_exists(self, queue_name):
# resp = self._channel.queue_declare(queue_name, passive=True,
# callback=self._queue_exists_clb)
try:
resp = self._channel.queue_declare(queue_name, passive=True)
except pika.exceptions.ChannelClosedByBro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queue_exists(name: str) -> bool:\n try:\n batch = aws.client_with_default_region(\"batch\")\n\n return bool(\n batch.describe_job_queues(jobQueues = [name]) \\\n .get(\"jobQueues\"))\n except:\n return False",
"def check_queue_exists(self, queue_name):\n ... | [
"0.8382494",
"0.80331993",
"0.7178421",
"0.6821361",
"0.6522141",
"0.6282557",
"0.62823933",
"0.6259214",
"0.6247339",
"0.6228033",
"0.6066524",
"0.6053394",
"0.5989296",
"0.59568065",
"0.59551704",
"0.5893848",
"0.5880719",
"0.58080995",
"0.5800476",
"0.57873005",
"0.5771296... | 0.8045337 | 1 |
Bind a queue to and exchange using a bindkey. | def bind_queue(self, exchange_name, queue_name, bind_key):
self.logger.info('Subscribed to topic: {}'.format(bind_key))
try:
self._channel.queue_bind(
exchange=exchange_name, queue=queue_name, routing_key=bind_key)
except Exception as exc:
raise exc | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def bind(\n self,\n exchange: ExchangeParamType,\n routing_key: Optional[str] = None,\n *,\n arguments: Arguments = None,\n timeout: TimeoutType = None,\n ) -> aiormq.spec.Queue.BindOk:\n\n if routing_key is None:\n routing_key = self.name\n\n ... | [
"0.81183326",
"0.8103516",
"0.7299756",
"0.72343296",
"0.6798707",
"0.66810113",
"0.6661785",
"0.6393759",
"0.6380712",
"0.61351526",
"0.6023554",
"0.60181004",
"0.5864606",
"0.5818092",
"0.5730135",
"0.56261426",
"0.5511071",
"0.5502747",
"0.54900175",
"0.54781646",
"0.53866... | 0.83013225 | 0 |
This method connects to RabbitMQ, returning the connection handle. When the connection is established, the on_connection_open method will be invoked by pika. | def connect(self):
self.logger.info("Connecting to AMQP broker @ [{}:{}] ...".format(
self._host, self._port))
connection = pika.SelectConnection(
pika.URLParameters(host=self.host, port=self.port),
on_open_callback=self.on_connection_open,
on_open_error_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect(self):\n logger.info(\"[{}] Connecting to exchange {}\".format(self.bot_id, self.exchange))\n creds = pika.PlainCredentials(self.rabbit_user, self.rabbit_pw)\n return pika.SelectConnection(pika.ConnectionParameters(host=self.rabbit_host,\n ... | [
"0.79583675",
"0.76922405",
"0.7413911",
"0.7396698",
"0.7392125",
"0.7361149",
"0.716752",
"0.7063484",
"0.6990006",
"0.6917834",
"0.69153863",
"0.69112873",
"0.6738685",
"0.6720706",
"0.66703725",
"0.65770364",
"0.6209485",
"0.6167131",
"0.6166281",
"0.61037654",
"0.6077000... | 0.8152155 | 0 |
This method adds an on close callback that will be invoked by pika when RabbitMQ closes the connection to the publisher unexpectedly. | def add_on_connection_close_callback(self):
self.logger.info('Adding connection close callback')
self._connection.add_on_close_callback(self.on_connection_closed) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_on_connection_close_callback(self):\n logger.info('Adding connection close callback')\n self._connection.add_on_close_callback(self.on_connection_closed)",
"def add_on_channel_close_callback(self):\n self.logger.info('Adding channel close callback')\n self._channel.add_on_clos... | [
"0.68998057",
"0.65204984",
"0.6488441",
"0.6387048",
"0.63626075",
"0.6320616",
"0.63115996",
"0.6273689",
"0.6253002",
"0.61269623",
"0.602197",
"0.59879506",
"0.5974477",
"0.59583783",
"0.5915136",
"0.5909586",
"0.59004337",
"0.5899694",
"0.58445156",
"0.58380735",
"0.5822... | 0.6884927 | 1 |
Open a new channel with RabbitMQ by issuing the Channel.Open RPC command. When RabbitMQ responds that the channel is open, the on_channel_open callback will be invoked by pika. | def open_channel(self):
self.logger.info('Creating a new channel')
self._connection.channel(on_open_callback=self.on_channel_open) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_channel(self):\n logger.info('Creating a new channel')\n self._connection.channel(on_open_callback=self.on_channel_open)",
"def open_channel(self):\n self.logger.info('creating channel')\n self._connection.channel(on_open_callback=self.on_channel_opened)",
"def open_channel... | [
"0.83642685",
"0.8301442",
"0.79944754",
"0.75968945",
"0.7201714",
"0.7161115",
"0.71372306",
"0.69947195",
"0.6949203",
"0.6906915",
"0.68744904",
"0.6814651",
"0.6694035",
"0.66927004",
"0.66060114",
"0.6562752",
"0.6420667",
"0.64157397",
"0.6349529",
"0.6260485",
"0.6246... | 0.8340857 | 1 |
Returns the transport used by the client instance. | def transport(self) -> TraceServiceTransport:
return self._client.transport | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transport(self):\n return self._transport",
"def transport(self) -> ServiceControllerTransport:\n return self._client.transport",
"def transport(self) -> MetadataServiceTransport:\n return self._client.transport",
"def transport(self) -> Controller2Transport:\n return self._cl... | [
"0.82946277",
"0.773594",
"0.773068",
"0.76806635",
"0.7674273",
"0.76357967",
"0.7558095",
"0.7551682",
"0.75303864",
"0.74958986",
"0.7488142",
"0.7436853",
"0.7423566",
"0.7368433",
"0.73340607",
"0.721926",
"0.7109823",
"0.7102308",
"0.68808985",
"0.68144",
"0.6671675",
... | 0.7887542 | 1 |
Instantiates the trace service client. | def __init__(
self,
*,
credentials: Optional[ga_credentials.Credentials] = None,
transport: Union[str, TraceServiceTransport] = "grpc_asyncio",
client_options: Optional[ClientOptions] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> Non... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_service_account_info(cls, info: dict, *args, **kwargs):\n return TraceServiceClient.from_service_account_info.__func__(TraceServiceAsyncClient, info, *args, **kwargs) # type: ignore",
"def init_tracing(tracer=None, start_span_cb=None):\n if start_span_cb is not None and not callable(start_spa... | [
"0.6224425",
"0.614903",
"0.6148861",
"0.6143238",
"0.60640776",
"0.60572755",
"0.6037",
"0.6000073",
"0.59515965",
"0.5935823",
"0.59356844",
"0.58780044",
"0.5807344",
"0.5730025",
"0.5720148",
"0.57108897",
"0.56886417",
"0.5663852",
"0.565965",
"0.56489265",
"0.56397253",... | 0.72883797 | 0 |
r"""Batch writes new spans to new or existing traces. You cannot update existing spans. | async def batch_write_spans(
self,
request: Optional[Union[tracing.BatchWriteSpansRequest, dict]] = None,
*,
name: Optional[str] = None,
spans: Optional[MutableSequence[trace.Span]] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, obje... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def emit(self, span_datas):\n spans = []\n for span_data in span_datas:\n start_timestamp_mus = timestamp_to_microseconds(span_data.start_time)\n end_timestamp_mus = timestamp_to_microseconds(span_data.end_time)\n duration_mus = end_timestamp_mus - start_timestamp_mus... | [
"0.6811375",
"0.60281205",
"0.5970347",
"0.57480675",
"0.5696596",
"0.56760955",
"0.5543506",
"0.55071294",
"0.5426647",
"0.5372521",
"0.5276325",
"0.52397996",
"0.52351356",
"0.5235073",
"0.52316785",
"0.5226964",
"0.519142",
"0.5142626",
"0.51129663",
"0.51124173",
"0.51083... | 0.6472164 | 1 |
Test the profile API endpoint GET response | def test_profile_api_get(self):
response = self.client.get(self.url)
self.assertEqual(response.status_code, 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_profiles(self):\n\n result = self.client.get(\"/profile/1\")\n self.assertIn(b'In house:',result.data)",
"def test_retrieve_profile_success(self):\r\n res = self.client.get(ME_URL)\r\n\r\n self.assertEqual(res.status_code, status.HTTP_200_OK)\r\n self.assertEqual(... | [
"0.78998727",
"0.78946996",
"0.78889894",
"0.78718877",
"0.7852061",
"0.78516936",
"0.7841847",
"0.7619126",
"0.75576365",
"0.7531133",
"0.7519396",
"0.75156456",
"0.75071",
"0.748667",
"0.7394794",
"0.7361457",
"0.73495585",
"0.73462677",
"0.73241436",
"0.72645575",
"0.72075... | 0.8666205 | 0 |
Test that anonymous users can't use the profile endpoint | def test_profile_api_anon(self):
self.client.logout()
response = self.client.get(self.url)
self.assertEqual(response.status_code, 403) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_anonymous_cannot_get_userprofileview(dclient):\n resp = dclient.get(\"/api/record/profile/\", follow=True)\n assert resp.status_code == 403",
"def test_user_get_profile_not_authorized(self):\n self.client.logout()\n response = self.client.get(CONSTS.USER_PROFILE_URL)\n self.as... | [
"0.82741946",
"0.79313326",
"0.7904038",
"0.735246",
"0.7276615",
"0.7208659",
"0.7133845",
"0.71277064",
"0.71277064",
"0.7126814",
"0.7056105",
"0.7036489",
"0.6996773",
"0.69937104",
"0.6974785",
"0.69686174",
"0.69459134",
"0.69378793",
"0.69362813",
"0.6936106",
"0.69107... | 0.83698225 | 0 |
Test the data_org_structure API endpoint | def test_data_org_structure(self):
url = '/api/options/?list=org_structure'
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
# Division 1 will be present in the response.
self.assertContains(response, self.div1.name)
# Response can be deserialis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_org_structure(self):\n url = '/api/users/?org_structure=true'\n response = self.client.get(url)\n self.assertEqual(response.status_code, 200)\n # User 1 will be present in the response.\n self.assertContains(response, self.user1.email)\n # Division 1 will be prese... | [
"0.7280201",
"0.7019675",
"0.69859654",
"0.698312",
"0.6874224",
"0.68411446",
"0.6755719",
"0.6737832",
"0.6731981",
"0.6727342",
"0.66614383",
"0.65936196",
"0.65404403",
"0.6487398",
"0.6469158",
"0.6427537",
"0.6424736",
"0.64159113",
"0.6405096",
"0.6384944",
"0.6375816"... | 0.79321814 | 0 |
Test the data_cost_centre API endpoint | def test_data_cost_centre(self):
url = '/api/options/?list=cost_centre'
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
# 001 will be present in the response.
self.assertContains(response, self.cc1.code)
# Add 'inactive' to Division 1 name to i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_costcenter_create(self):\n response = self.client.post(self.url, self.data, format='json')\n self.assertEqual(response.status_code, status.HTTP_201_CREATED)\n self.assertEqual(CostCenter.objects.latest('pk').name, 'testCostCenter')",
"def test_costcenter_permissions(self):\n ... | [
"0.64706284",
"0.6464512",
"0.643265",
"0.63336295",
"0.62168723",
"0.61924493",
"0.6173499",
"0.6118328",
"0.6030371",
"0.59304565",
"0.588217",
"0.58735037",
"0.58357346",
"0.5835226",
"0.5833968",
"0.58259165",
"0.58216953",
"0.5815268",
"0.5794791",
"0.5775297",
"0.575300... | 0.75237375 | 0 |
Test the data_org_unit API endpoint | def test_data_org_unit(self):
url = '/api/options/?list=org_unit'
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
# Org unit names will be present in the response.
self.assertContains(response, self.dept.name)
self.assertContains(response, self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_org_unit_types_retrieve_ok(self):\n\n self.client.force_authenticate(self.jane)\n response = self.client.get(f\"/api/orgunittypes/{self.org_unit_type_1.id}/\")\n self.assertJSONResponse(response, 200)\n self.assertValidOrgUnitTypeData(response.json())",
"def test_api_response... | [
"0.7054267",
"0.69409764",
"0.68107057",
"0.677534",
"0.6769197",
"0.6747698",
"0.66711855",
"0.66707194",
"0.6649014",
"0.6616306",
"0.65697694",
"0.6565859",
"0.65644926",
"0.6545995",
"0.6535199",
"0.65209496",
"0.6512976",
"0.64967656",
"0.6492492",
"0.64836305",
"0.64805... | 0.78380704 | 0 |
Test the data_dept_user API endpoint | def test_data_dept_user(self):
url = '/api/options/?list=dept_user'
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
# User 1 will be present in the response.
self.assertContains(response, self.user1.email)
# Make a user inactive to test excludi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_api_user_get(self):\n pass",
"def test_api_can_get_department_by_id(self):\n res = self.client().get(service_url+'/1')\n self.assertEqual(res.status_code, 200)\n self.assertIn('dep 1', str(res.data))",
"def test_department_list_view_does_not_require_login(self):\n\n ... | [
"0.6911616",
"0.6585779",
"0.65574944",
"0.6486932",
"0.6429227",
"0.6393024",
"0.6330526",
"0.6287828",
"0.62805206",
"0.62287253",
"0.62287253",
"0.6190859",
"0.61889917",
"0.6157453",
"0.61065644",
"0.61012024",
"0.60839427",
"0.6061331",
"0.60579497",
"0.6019481",
"0.5989... | 0.78939223 | 0 |
Test the DepartmentUserResource list responses | def test_list(self):
url = '/api/users/'
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
r = response.json()
self.assertTrue(isinstance(r['objects'], list))
# Response should not contain inactive, contractors or shared accounts.
self.as... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_data_dept_user(self):\n url = '/api/options/?list=dept_user'\n response = self.client.get(url)\n self.assertEqual(response.status_code, 200)\n # User 1 will be present in the response.\n self.assertContains(response, self.user1.email)\n # Make a user inactive to t... | [
"0.70617765",
"0.6896499",
"0.6760332",
"0.67289186",
"0.6697319",
"0.66882765",
"0.6570206",
"0.647242",
"0.6395878",
"0.6352461",
"0.6339239",
"0.62306577",
"0.6206826",
"0.6193651",
"0.61818725",
"0.6169891",
"0.61679596",
"0.61593413",
"0.6158925",
"0.6155703",
"0.6143452... | 0.7140781 | 0 |
Test the DepartmentUserResource org_structure response | def test_org_structure(self):
url = '/api/users/?org_structure=true'
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
# User 1 will be present in the response.
self.assertContains(response, self.user1.email)
# Division 1 will be present in the r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_data_org_structure(self):\n url = '/api/options/?list=org_structure'\n response = self.client.get(url)\n self.assertEqual(response.status_code, 200)\n # Division 1 will be present in the response.\n self.assertContains(response, self.div1.name)\n # Response can be... | [
"0.7079402",
"0.6818299",
"0.66625524",
"0.64964676",
"0.63513947",
"0.6324385",
"0.6287517",
"0.624722",
"0.6163514",
"0.607215",
"0.6066868",
"0.6002692",
"0.60003984",
"0.5983165",
"0.59071344",
"0.5842544",
"0.58366925",
"0.58230346",
"0.5792428",
"0.57868",
"0.57077533",... | 0.7828602 | 0 |
Test the sync_o365=true request parameter | def test_org_structure_sync_0365(self):
self.div1.sync_o365 = False
self.div1.save()
url = '/api/users/?org_structure=true&sync_o365=true'
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
# Division 1 won't be present in the response.
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update(self):\n tz = pytz.timezone(settings.TIME_ZONE)\n self.assertFalse(self.user1.o365_licence)\n url = '/api/users/{}/'.format(self.user1.ad_guid)\n data = {\n 'Surname': 'Lebowski',\n 'title': 'Bean Counter',\n 'o365_licence': True,\n\n ... | [
"0.5523401",
"0.5490021",
"0.5473076",
"0.5389904",
"0.5329667",
"0.5279898",
"0.5278388",
"0.52731276",
"0.5264166",
"0.5212756",
"0.520137",
"0.5167739",
"0.5163394",
"0.5136898",
"0.5109988",
"0.509473",
"0.5079237",
"0.5046441",
"0.50332296",
"0.5016915",
"0.50153786",
... | 0.63471866 | 0 |
Test the DepartmentUserResource create response with valid data | def test_create_valid(self):
url = '/api/users/'
username = str(uuid1())[:8]
data = {
'EmailAddress': '{}@dbca.wa.gov.au'.format(username),
'DisplayName': 'Doe, John',
'SamAccountName': username,
'DistinguishedName': 'CN={},OU=Users,DC=domain'.form... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_valid_alt(self):\n url = '/api/users/'\n username = str(uuid1())[:8]\n data = {\n 'email': '{}@dbca.wa.gov.au'.format(username),\n 'name': 'Doe, John',\n 'username': username,\n 'ad_dn': 'CN={},OU=Users,DC=domain'.format(username),\n ... | [
"0.818291",
"0.7483183",
"0.74106675",
"0.7328781",
"0.7323043",
"0.7190883",
"0.7050981",
"0.7025523",
"0.70017236",
"0.6995397",
"0.6940708",
"0.69277716",
"0.6915937",
"0.6911802",
"0.68888426",
"0.688786",
"0.68668306",
"0.6850452",
"0.684756",
"0.68334687",
"0.6804259",
... | 0.83909786 | 0 |
Test the DepartmentUserResource create response with alternate parameter names | def test_create_valid_alt(self):
url = '/api/users/'
username = str(uuid1())[:8]
data = {
'email': '{}@dbca.wa.gov.au'.format(username),
'name': 'Doe, John',
'username': username,
'ad_dn': 'CN={},OU=Users,DC=domain'.format(username),
'e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_valid(self):\n url = '/api/users/'\n username = str(uuid1())[:8]\n data = {\n 'EmailAddress': '{}@dbca.wa.gov.au'.format(username),\n 'DisplayName': 'Doe, John',\n 'SamAccountName': username,\n 'DistinguishedName': 'CN={},OU=Users,DC=... | [
"0.72510594",
"0.67844975",
"0.6702618",
"0.66944396",
"0.6694119",
"0.65534997",
"0.6493329",
"0.6493242",
"0.64452225",
"0.64258426",
"0.63768077",
"0.63703567",
"0.6356024",
"0.6324553",
"0.6317689",
"0.6305012",
"0.6266619",
"0.62521505",
"0.6219614",
"0.6197601",
"0.6192... | 0.7325158 | 0 |
Test the DepartmentUserResource update response | def test_update(self):
tz = pytz.timezone(settings.TIME_ZONE)
self.assertFalse(self.user1.o365_licence)
url = '/api/users/{}/'.format(self.user1.ad_guid)
data = {
'Surname': 'Lebowski',
'title': 'Bean Counter',
'o365_licence': True,
'email... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_update_request(self):\n pass",
"def test_update_user(self):\n pass",
"def test_user_update(self):\n userPK = self.testUser.pk\n url = reverse('User-detail', kwargs={'pk': userPK})\n data = {'username': 'company1NewTest'}\n response = self.client.put(url, ... | [
"0.74304736",
"0.7100337",
"0.7083804",
"0.7059448",
"0.70498127",
"0.7006222",
"0.6972898",
"0.69647837",
"0.6948436",
"0.6912053",
"0.6911955",
"0.6867315",
"0.6849965",
"0.68217105",
"0.68207514",
"0.6787449",
"0.6785152",
"0.67461604",
"0.67318773",
"0.6691769",
"0.665955... | 0.7544808 | 0 |
Test the DepartmentUserResource update response (set user as inactive) | def test_disable(self):
self.assertTrue(self.user1.active)
self.assertFalse(self.user1.ad_deleted)
url = '/api/users/{}/'.format(self.user1.ad_guid)
data = {
'Enabled': False,
}
response = self.client.put(url, json.dumps(data), content_type='application/json')... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_data_dept_user(self):\n url = '/api/options/?list=dept_user'\n response = self.client.get(url)\n self.assertEqual(response.status_code, 200)\n # User 1 will be present in the response.\n self.assertContains(response, self.user1.email)\n # Make a user inactive to t... | [
"0.6705734",
"0.665646",
"0.6515721",
"0.6420796",
"0.6402472",
"0.63838017",
"0.6368533",
"0.6187678",
"0.61713004",
"0.6147244",
"0.6120597",
"0.6083781",
"0.60777783",
"0.6072792",
"0.6065049",
"0.6060552",
"0.6054846",
"0.6045528",
"0.60311913",
"0.6006138",
"0.5993923",
... | 0.7478637 | 0 |
Test the DepartmentUserResource update response (set user as 'AD deleted') | def test_delete(self):
self.assertFalse(self.user1.ad_deleted)
self.assertTrue(self.user1.active)
url = '/api/users/{}/'.format(self.user1.ad_guid)
data = {'Deleted': True}
response = self.client.put(url, json.dumps(data), content_type='application/json')
self.assertEqual... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_disable(self):\n self.assertTrue(self.user1.active)\n self.assertFalse(self.user1.ad_deleted)\n url = '/api/users/{}/'.format(self.user1.ad_guid)\n data = {\n 'Enabled': False,\n }\n response = self.client.put(url, json.dumps(data), content_type='applic... | [
"0.6858798",
"0.673273",
"0.6596995",
"0.6502775",
"0.6428381",
"0.6339772",
"0.63135546",
"0.6285482",
"0.62707835",
"0.6264158",
"0.6246897",
"0.6209684",
"0.62034184",
"0.6203136",
"0.61618066",
"0.61393726",
"0.6103969",
"0.60593694",
"0.6054395",
"0.6054395",
"0.60507435... | 0.7495284 | 0 |
Test the LocationResource list response | def test_list(self):
loc_inactive = mixer.blend(Location, manager=None, active=False)
url = '/api/locations/'
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
# Response should not contain the inactive Location.
self.assertNotContains(response, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_locations(self):\n url = reverse(\"locations\", args=[00000])\n response = self.client.get(url)\n\n self.assertEqual(response.status_code, status.HTTP_200_OK)\n self.assertTrue(isinstance(response.data, list))\n self.assertTrue(response.data) # list not empty\n\n ... | [
"0.75615865",
"0.73977536",
"0.7293898",
"0.7004044",
"0.68876386",
"0.67524344",
"0.6536098",
"0.653123",
"0.6502782",
"0.6500661",
"0.64945704",
"0.6477591",
"0.6466978",
"0.6464637",
"0.6457173",
"0.6457173",
"0.643977",
"0.6437493",
"0.6426901",
"0.6372002",
"0.636272",
... | 0.74700975 | 1 |
Test the LocationResource filtered response | def test_filter(self):
url = '/api/locations/?location_id={}'.format(self.loc1.pk)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertContains(response, self.loc1.name)
# We can still return inactive locations by ID
loc_inactive = mixer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_viewset_list_filter(self):\n # valid coordinate within a zone\n data = {\"coords\": \"55.710663495702725/9.52840811021021\"}\n response = self.client.get(reverse(\"servicearea-list\"), data, format='json')\n\n # we should get a http 200 and the zone\n self.assertEqual(re... | [
"0.6681495",
"0.66567737",
"0.6653688",
"0.66046005",
"0.6528886",
"0.64084023",
"0.6384683",
"0.6360479",
"0.6327835",
"0.6174376",
"0.6027128",
"0.59949857",
"0.5966776",
"0.5947426",
"0.5935014",
"0.5918347",
"0.5887104",
"0.58725655",
"0.5836169",
"0.583044",
"0.5819339",... | 0.7458695 | 0 |
Helper function to call become plugin simiarly on how Ansible itself handles this. | def call_become_plugin(task, var_options, cmd, executable=None):
plugin = become_loader.get(task['become_method'])
plugin.set_options(task_keys=task, var_options=var_options)
shell = get_shell_plugin(executable=executable)
return plugin.build_become_command(cmd, shell) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def playbook_on_start(this):\n\n # Monkey-patch ansible.playbook.task.Task\n import ansible.playbook.task\n\n class T(ansible.playbook.task.Task):\n VALID_KEYS = ansible.playbook.task.Task.VALID_KEYS.union({'run_once_per'})\n\n def __init__(self, play, ds, **kwargs):\n ... | [
"0.5598071",
"0.5544143",
"0.55433804",
"0.55309314",
"0.54727757",
"0.54650944",
"0.5433382",
"0.5429682",
"0.53782296",
"0.5356523",
"0.53534186",
"0.51360434",
"0.50613815",
"0.48578998",
"0.48062238",
"0.47975665",
"0.4780355",
"0.47606272",
"0.47257707",
"0.46939725",
"0... | 0.71577346 | 0 |
Gets all the days from today until the end of the month. | def get_days(start_day, month_count: int = 1) -> List[Day]:
assert type(start_day) is Day
assert type(month_count) is int
start = start_day.to_date_time()
days = list(rrule(MONTHLY, count=month_count * 2, bymonthday=(-1, 1,), dtstart=start))
return Calendar.fill(Day(days[0]), Da... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAllDays(self):\n start = str(self.current[0:10])\n end = str(self.dueDate[0:10])\n daysRange = pd.date_range(start = start, end = end).tolist()\n daysRange = daysRange[1:len(daysRange)-1]\n days = []\n for i in daysRange:\n day = str(i)\n day =... | [
"0.69140226",
"0.6511607",
"0.638647",
"0.6041111",
"0.59826064",
"0.59621537",
"0.5925641",
"0.5920649",
"0.58771974",
"0.5869278",
"0.58284515",
"0.5811526",
"0.581057",
"0.5739362",
"0.5698352",
"0.5691271",
"0.5685953",
"0.56856126",
"0.56745434",
"0.56403077",
"0.5640276... | 0.6592042 | 1 |
Returns all the days for the provided week day in a month. | def get_week_days(start_day: Day, weekday_number: int, month_count: int) -> List[Day]:
assert type(start_day) is Day
assert type(weekday_number) is int
assert type(month_count) is int
start = start_day.to_date_time()
end = start + relativedelta(months=month_count)
days =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_work_week_days(start_day: Day, month_count: int) -> List[Day]:\n assert type(start_day) is Day\n assert type(month_count) is int\n\n start = start_day.to_date_time()\n end = start + relativedelta(months=month_count)\n days = list(rrule(DAILY, wkst=MO, byweekday=(MO, TU, W... | [
"0.6844833",
"0.6423875",
"0.638872",
"0.63580483",
"0.6291826",
"0.6276168",
"0.61245525",
"0.61162984",
"0.6059549",
"0.605568",
"0.60542864",
"0.6043643",
"0.5857643",
"0.5835116",
"0.5813211",
"0.570522",
"0.56851107",
"0.5675388",
"0.5672337",
"0.5669654",
"0.56690675",
... | 0.6708884 | 1 |
Gets all days within a work week from today until the end of the month | def get_work_week_days(start_day: Day, month_count: int) -> List[Day]:
assert type(start_day) is Day
assert type(month_count) is int
start = start_day.to_date_time()
end = start + relativedelta(months=month_count)
days = list(rrule(DAILY, wkst=MO, byweekday=(MO, TU, WE, TH, FR),... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dates_of_the_week():\n date_list = list()\n now = datetime.datetime.now()\n monday = now - datetime.timedelta(days=now.weekday(), hours=now.hour, minutes=now.minute, seconds=now.second,\n microseconds=now.microsecond)\n date_list.append(monday)\n for each in ... | [
"0.7065504",
"0.6642577",
"0.6616175",
"0.6610579",
"0.64627105",
"0.64162827",
"0.6385287",
"0.6337657",
"0.6333118",
"0.6311995",
"0.6309436",
"0.630006",
"0.6294607",
"0.6228853",
"0.621049",
"0.62000245",
"0.617651",
"0.6172212",
"0.61515874",
"0.60586876",
"0.6044418",
... | 0.7435883 | 0 |
Gets the relevant shas given the start date, end date and interval on the given branch. | def get_dates_and_shas(branch, start, end, interval):
shas = []
dates = []
if interval == 0:
# If interval is 0, simply get all the non-merge commits and find
# their dates
revlist = subprocess.Popen(['git', 'rev-list', '--since', str(start),
'--before', str(end), '--no-merges', branch],
stdout=su... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spline_branch(self,branch,interval=1.0):\n\t\t\n\t\tnumber_of_points = int(round(self.branchLength(branch)/interval,0))+1\n\t\tline = LineString([tuple(point[:3]) for point in branch])\n\t\tsplitter = MultiPoint([line.interpolate((i/number_of_points),normalized=True) for i in range(number_of_points+1)])\n\t\ti... | [
"0.5246796",
"0.48593053",
"0.4788723",
"0.45969608",
"0.45834252",
"0.45441726",
"0.45159206",
"0.44913507",
"0.44680756",
"0.44357204",
"0.43516868",
"0.43506223",
"0.4348679",
"0.4344899",
"0.43400103",
"0.43250442",
"0.43206328",
"0.43109226",
"0.4303643",
"0.42983198",
"... | 0.75405824 | 0 |
Calculates the total churn of commits described in dateshas after filtering out the excluded paths. | def get_churn_with_interval(dateshas, excludestr):
print "sha1;date1;sha2;date2;churn" # CSV header line
total = 0
date, sha = dateshas[0]
for prevdate, prevsha in dateshas[1:]:
diff = None
if excludestr:
# See function get_churn_per_commit for an explanation per
# process call
files = subprocess.Pope... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_churn_per_commit(dateshas, excludestr):\n\tprint \"sha;date;churn\" # CSV header line\n\ttotal = 0\n\tfor date, sha in dateshas:\n\t\tcommit = None\n\t\tif excludestr:\n\t\t\t# Example command with filtering:\n\t\t\t# git show abcde -w -C --name-status --format=format: \n\t\t\t#\t\tOutputs all the changed ... | [
"0.72989583",
"0.5401435",
"0.51254535",
"0.50825906",
"0.49629587",
"0.49015906",
"0.48703545",
"0.48519665",
"0.48055995",
"0.47520775",
"0.46931726",
"0.46821773",
"0.46621984",
"0.4652477",
"0.464813",
"0.46309492",
"0.45973372",
"0.45786098",
"0.45642877",
"0.45621127",
... | 0.7305681 | 0 |
Calculates the total churn of commits described in dateshas after filtering out the excluded paths. | def get_churn_per_commit(dateshas, excludestr):
print "sha;date;churn" # CSV header line
total = 0
for date, sha in dateshas:
commit = None
if excludestr:
# Example command with filtering:
# git show abcde -w -C --name-status --format=format:
# Outputs all the changed files with just their filenames, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_churn_with_interval(dateshas, excludestr):\n\tprint \"sha1;date1;sha2;date2;churn\" # CSV header line\n\ttotal = 0\n\tdate, sha = dateshas[0]\n\tfor prevdate, prevsha in dateshas[1:]:\n\t\tdiff = None\n\t\tif excludestr:\n\t\t\t# See function get_churn_per_commit for an explanation per \n\t\t\t# process ca... | [
"0.7305681",
"0.5401435",
"0.51254535",
"0.50825906",
"0.49629587",
"0.49015906",
"0.48703545",
"0.48519665",
"0.48055995",
"0.47520775",
"0.46931726",
"0.46821773",
"0.46621984",
"0.4652477",
"0.464813",
"0.46309492",
"0.45973372",
"0.45786098",
"0.45642877",
"0.45621127",
"... | 0.72989583 | 1 |
Function vararg_callback An extention on OptParser to parse a varying amount of argument, in this case used for the x flag. | def vararg_callback(option, opt_str, value, parser):
assert value is None
value = []
def floatable(str):
try:
float(str)
return True
except ValueError:
return False
for arg in parser.rargs:
# Stop on options like --foo
if arg[:2] == "--" and len(arg) > 2:
break
# Stop on -a, but not on nega... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def argparse_callback(parser: argparse.ArgumentParser):\n parser.add_argument(\n '--my-custom-flag', default=\"Default value\", type=str, help='My custom flag'\n )",
"def _argument_adapter(callback):\n def wrapper(*args, **kwargs):\n if kwargs or len(args) > 1:\n callback(Argume... | [
"0.56956077",
"0.5579839",
"0.5338161",
"0.5259655",
"0.5250685",
"0.52107143",
"0.5143298",
"0.5102959",
"0.5097259",
"0.50921047",
"0.50836056",
"0.5052569",
"0.5029265",
"0.5027403",
"0.49902073",
"0.49874467",
"0.496362",
"0.49565348",
"0.49565348",
"0.4903791",
"0.489057... | 0.70214987 | 0 |
Add a store location | def add_location(self, **kwargs):
self.options.update(kwargs)
self.options['action'] = 'locator.location.add'
return self.call(self.options) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def StoreLocation(self) -> str:",
"def add_location(db_path: str, location: Location) -> None:\n query = f'INSERT INTO locations (name, area, climate) VALUES (\"{location.name}\", {location.area}, {location.climate.climate_type})'\n\n conn: Connection = sqlite3.connect(path.join(db_path, 'company_data.db')... | [
"0.68922573",
"0.66731364",
"0.6477832",
"0.637889",
"0.6161532",
"0.6137485",
"0.6105172",
"0.6104328",
"0.6104328",
"0.6104328",
"0.6104328",
"0.6104328",
"0.6104328",
"0.6104328",
"0.6088784",
"0.60743314",
"0.6058797",
"0.6046716",
"0.6001751",
"0.6000176",
"0.59155136",
... | 0.7235024 | 0 |
Get details of a location in a store locator | def location_details(self, **kwargs):
self.options.update(kwargs)
self.options['action'] = 'locator.location.details'
return self.call(self.options) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_location(self):\n return self.request({\n \"path\": \"/\" + UUID + \"/location\"\n })",
"def get_location(self):\n return self.location",
"def _get_location_details(self, location):\n resp = requests.get(\n self.base_url,\n params = {\n ... | [
"0.7287444",
"0.72388345",
"0.7233243",
"0.703261",
"0.6991874",
"0.69567317",
"0.6938865",
"0.6914896",
"0.68907416",
"0.68650895",
"0.6812407",
"0.67199504",
"0.6700374",
"0.66257614",
"0.6614068",
"0.65762717",
"0.656604",
"0.6555892",
"0.65359735",
"0.65218616",
"0.651035... | 0.7368558 | 0 |
Remove a location from a store locator | def remove_location(self, **kwargs):
self.options.update(kwargs)
self.options['action'] = 'locator.location.remove'
return self.call(self.options) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_location(self, location_id):",
"def delete_loc(lat, lon):\n\tredis_server = SETTINGS['REDIS_IP']\n\tredis_session = redis.StrictRedis(host=redis_server,\\\n\t\t\t\t\t\t\tport=6379, db=0)\n\tredis_session.zrem(\"all_loc\", str(str(lon), str(lat)))",
"def removelocation(self, location):\n found... | [
"0.74674547",
"0.6915386",
"0.6857918",
"0.6857918",
"0.6857918",
"0.6857918",
"0.6857918",
"0.6857918",
"0.6857918",
"0.6838363",
"0.659987",
"0.65884995",
"0.6565125",
"0.65502083",
"0.6539492",
"0.6524253",
"0.65041393",
"0.64223635",
"0.62793577",
"0.61533785",
"0.6065900... | 0.8073628 | 0 |
Update configuration of a location | def update_location(self, **kwargs):
self.options.update(kwargs)
self.options['action'] = 'locator.location.update'
return self.call(self.options) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config_location(self):\n\n # show current location\n self.app.stdout.write(\"Current location\\n\")\n self.app.stdout.write(f\"{self.Location}\\n\")\n self.app.stdout.write('\\n')\n\n # choose new location\n location_set = self.browse_location()\n self.set_locat... | [
"0.7021159",
"0.6805759",
"0.6768406",
"0.6389433",
"0.6281382",
"0.623813",
"0.6155685",
"0.6113912",
"0.61124575",
"0.61106986",
"0.6061526",
"0.6059167",
"0.60387474",
"0.60103077",
"0.6009843",
"0.59543437",
"0.59473723",
"0.59142107",
"0.5896123",
"0.58798623",
"0.584419... | 0.69828993 | 1 |
Test that a ``GET /account/settings`` returns the settings for the session user. | async def test_get_settings(spawn_client):
client = await spawn_client(authorize=True)
resp = await client.get("/account/settings")
assert resp.status == 200
assert await resp.json() == {
"skip_quick_analyze_dialog": True,
"show_ids": True,
"show_versions": True,
"quic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_account_settings(self):\n settings = AccountSettings(self.client, False, {})\n\n self.assertEqual(settings.longview_subscription.id, \"longview-100\")\n self.assertEqual(settings.managed, False)\n self.assertEqual(settings.network_helper, False)\n self.assertEqual(se... | [
"0.7293422",
"0.6904159",
"0.68857753",
"0.67829",
"0.6742984",
"0.6587807",
"0.65675956",
"0.65069836",
"0.6502907",
"0.6484014",
"0.6447866",
"0.6412865",
"0.6388406",
"0.6352493",
"0.6341707",
"0.6281831",
"0.62814415",
"0.62814415",
"0.6279597",
"0.6249542",
"0.6220485",
... | 0.71580607 | 1 |
Tests that when an invalid permission is used, validators.is_permission_dict raises a 422 error. | async def test_is_permission_dict(value, spawn_client, resp_is):
client = await spawn_client(authorize=True)
permissions = {
Permission.cancel_job.value: True,
Permission.create_ref.value: True,
Permission.create_sample.value: True,
Permission.modify_hmm.value: True,
}
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_permissions(permission, payload):\n if 'permissions' not in payload:\n abort(401)\n\n if permission not in payload['permissions']:\n abort(401)\n\n return True",
"def test_wrong_permission(self):\n with self.assertRaises(InvalidPermissionStringError):\n client_h... | [
"0.66814137",
"0.6591706",
"0.6436258",
"0.6376614",
"0.6225889",
"0.614307",
"0.5958166",
"0.592137",
"0.592137",
"0.592137",
"0.592137",
"0.5903146",
"0.5903146",
"0.58885974",
"0.58770496",
"0.5861494",
"0.58467174",
"0.5839908",
"0.5837318",
"0.57968867",
"0.5785536",
"... | 0.6642042 | 1 |
Informs for the message broker that event message was rejected. | async def reject_event(self, envelope: Envelope, requeue: bool = False) -> None:
await self.channel.basic_reject(
delivery_tag=envelope.delivery_tag, requeue=requeue
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_reject(self):\n self.state = REJECTED\n self._reject()",
"def m_ts_OrderRejected(self, sender, e):\r\n print(\"Order was rejected. {0}\".format(e.Message))",
"def on_buttonBox_rejected(self):\n self.reject()",
"async def onRejected( # type: ignore[override]\n self, ... | [
"0.7376357",
"0.66578037",
"0.6633302",
"0.650125",
"0.63836914",
"0.6290341",
"0.62653553",
"0.6171732",
"0.6170672",
"0.61640024",
"0.61493176",
"0.6098134",
"0.6087443",
"0.6061216",
"0.5989285",
"0.5976502",
"0.5968853",
"0.595685",
"0.5894163",
"0.5869914",
"0.58388615",... | 0.7038541 | 1 |
Configure qos feature in the subscriber channel. | async def qos(
self,
prefetch_size: int = 0,
prefetch_count: int = 0,
connection_global: bool = False,
):
await self.channel.basic_qos(
prefetch_size=prefetch_size,
prefetch_count=prefetch_count,
connection_global=connection_global,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_qos(self, on_ok):\n self._channel.basic_qos(\n prefetch_count=self._prefetch_count, callback=on_ok)",
"def qos_type(self, qos_type):\n\n self._qos_type = qos_type",
"def set_qos(self, qos, set_specs_args):\n self._impl.set_qos(qos.id, set_specs_args)\n return self... | [
"0.6994104",
"0.6917727",
"0.66590065",
"0.64854676",
"0.6458646",
"0.64513636",
"0.6413767",
"0.62722945",
"0.6259844",
"0.6248928",
"0.6144506",
"0.60625154",
"0.6042893",
"0.5847944",
"0.58474493",
"0.58474493",
"0.58474493",
"0.5847176",
"0.57718706",
"0.57582027",
"0.568... | 0.695466 | 1 |
Count tree occurrences when traversing `m` on `slope`. | def solve_for(m: Map, slope: Coordinates) -> int:
n_trees = h = w = 0
h_step, w_step = slope
while h < m.max_h:
n_trees += m[h, w] == "#"
h += h_step
w += w_step
return n_trees | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def leaf_count(T):\n if T.is_leaf:\n return 1\n else:\n# s = 0\n# for child in T:\n# s += leaf_count(child)\n# return s\n return reduce(add, map(leaf_count, T))",
"def count_trees(matrix, dx, dy):\n\n # We begin in the upper left corner\n x = 0\n y = 0... | [
"0.6242175",
"0.618104",
"0.6117079",
"0.6071778",
"0.59382737",
"0.57623035",
"0.570038",
"0.56910276",
"0.5621603",
"0.55228496",
"0.54363155",
"0.5398564",
"0.53712696",
"0.53538644",
"0.53342783",
"0.5333687",
"0.53148955",
"0.5304808",
"0.52953374",
"0.5286473",
"0.52812... | 0.73680854 | 0 |
Load a feather of amino acid counts for a protein. | def load_feather(protein_feather, length_filter_pid=None, copynum_scale=False, copynum_df=None):
protein_df = pd.read_feather(protein_feather).set_index('index')
# Combine counts for residue groups
from ssbio.protein.sequence.properties.residues import _aa_property_dict_one, EXTENDED_AA_PROPERTY_DICT_ONE
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def codon_frequency(seq, aminoacid):\n tmpList = []\n for i in range(0, len(seq) - 2, 3):\n if CodonTable[seq[i:i + 3]] == aminoacid:\n tmpList.append(seq[i:i + 3])\n\n freqDict = dict(Counter(tmpList))\n totalScore = sum(freqDict.values())\n for seq in freqDict:\n freqDict[... | [
"0.5596277",
"0.5492704",
"0.53756523",
"0.519119",
"0.5187027",
"0.51630163",
"0.50907207",
"0.5074862",
"0.50250167",
"0.5022161",
"0.49966186",
"0.49030453",
"0.4886083",
"0.48618254",
"0.48587584",
"0.47983077",
"0.47870308",
"0.47677997",
"0.47620273",
"0.47374693",
"0.4... | 0.6117666 | 0 |
Resolve a list of effects, replacing random distributions with samples from them. It converts every number to string to match the expectations of torchaudio. | def sample_effects(self) -> List[List[str]]:
return [
[
str(item.sample() if isinstance(item, RandomValue) else item)
for item in effect
]
for effect in self.effects
] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_all_effects(all_effects):\n # format all effects\n fmt_all_effects = []\n for eff in all_effects:\n gene_name = eff['Hugo_Symbol'] if eff['Hugo_Symbol'] else ''\n effect_type = eff['One_Consequence']\n protein_change = eff['HGVSp_Short'] if eff.get('HGVSp_Short') el... | [
"0.5677834",
"0.5586095",
"0.5448812",
"0.5331068",
"0.51997465",
"0.50951654",
"0.50077164",
"0.4994568",
"0.49366093",
"0.49105924",
"0.4897263",
"0.48967674",
"0.48934194",
"0.4862928",
"0.48131192",
"0.4800036",
"0.4800036",
"0.47897625",
"0.4766505",
"0.47561795",
"0.474... | 0.68593466 | 0 |
Retrieving a tracing configuration file | def get(isamAppliance, instance_id, check_mode=False, force=False):
return isamAppliance.invoke_get("Retrieving a tracing configuration file",
"{0}/{1}/tracing_configuration".format(uri, instance_id),
requires_modules=requires_modules, requires... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_config(self, config_filename):",
"def config_file(self):\n return self[CONFIG_FILE_KEY]",
"def config_locator():\n print(pkgrs.resource_filename('latools', 'latools.cfg'))\n return",
"def get_config_file(config_file):\n if os.path.isfile(config_file):\n return config_file\n ... | [
"0.65861887",
"0.6201471",
"0.59921926",
"0.59153795",
"0.5883415",
"0.5848848",
"0.5817266",
"0.58134186",
"0.581149",
"0.58110315",
"0.58077043",
"0.5786387",
"0.5786206",
"0.57854015",
"0.5768189",
"0.5768189",
"0.5762999",
"0.5759536",
"0.57474333",
"0.57328016",
"0.57271... | 0.6589118 | 0 |
Checks if the file to be imported is the same as the file that's already on the instance | def _check_import(isamAppliance, id, filepath):
tmpdir = get_random_temp_dir()
tmp_original_file = os.path.join(tmpdir, os.path.basename("tempfile.txt"))
export_file(isamAppliance, instance_id=id, filepath=tmp_original_file, check_mode=False, force=True)
if files_same(tmp_original_file, filepath):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dupe_imports(self):\r\n good_file = self._get_del_file()\r\n imp = Importer(good_file, username=u\"admin\")\r\n imp.process()\r\n\r\n good_file = self._get_del_file()\r\n imp = Importer(good_file, username=u\"admin\")\r\n imp.process()\r\n\r\n # now let's d... | [
"0.6489134",
"0.6460151",
"0.63492894",
"0.6330165",
"0.6237938",
"0.6193168",
"0.61540926",
"0.61357623",
"0.61025244",
"0.60976493",
"0.60797423",
"0.60688674",
"0.60449314",
"0.60211533",
"0.6008159",
"0.5987599",
"0.59309274",
"0.5908474",
"0.5878707",
"0.58716476",
"0.58... | 0.68644285 | 0 |
Create a simple form generator the populates the choices from a list of Poll objects | def get_choice(cls, polls):
cl = cls()
items = []
for poll in polls:
items.append((poll.id, poll.question))
setattr(cl.poll, 'items', items)
return cl | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, choices, *args, **kwargs):\n super(RangePollChoiceForm, self).__init__(*args, **kwargs)\n nominees = [(i, '%d' % i) for i in range(0, choices.count()+1)]\n for choice in choices:\n self.fields['range_poll__%s' % str(choice.id)] = (\n forms.ChoiceFie... | [
"0.7152413",
"0.6911527",
"0.6545342",
"0.61729306",
"0.5988688",
"0.5907622",
"0.5904008",
"0.5762562",
"0.57005036",
"0.56966144",
"0.56839067",
"0.55775195",
"0.55669415",
"0.5556159",
"0.55277395",
"0.551386",
"0.55103374",
"0.55000895",
"0.5446568",
"0.5429533",
"0.54105... | 0.694909 | 1 |
Helper function to list protocol buffer fields | def fields(proto):
return [x[0].name for x in proto.ListFields()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_proto_fields():\n raise NotImplementedError()",
"def list_fields(fc):\n return [f.name for f in arcpy.ListFields(fc)]",
"def _list_fields(self):\n return list(self._state.keys())",
"def getFields(iface):\n return getFieldsInOrder(iface)",
"def fields(self):",
"def get_fields_l... | [
"0.74497396",
"0.7188583",
"0.6732649",
"0.6660771",
"0.66101354",
"0.6575934",
"0.6503095",
"0.64481694",
"0.6414286",
"0.63747007",
"0.6358524",
"0.6334771",
"0.62941283",
"0.6234232",
"0.6233044",
"0.6232955",
"0.62042385",
"0.61363804",
"0.6134944",
"0.61275667",
"0.61232... | 0.798349 | 0 |
Joins mgm and lfn, ensures correct formatting | def _join_mgm_lfn(self, mgm, lfn):
if not mgm.endswith('/'): mgm += '/'
return mgm + lfn | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def result_to_pretty_string(f, g, rs, ss, ts):\n\n return '\\n'.join(map(lambda (r, s, t): '{r} = ({s}) * ({f}) + ({t}) * ({g})'.format(r=r, s=s, t=t, f=f, g=g),\n zip(rs, ss, ts)))",
"def get_M_as_string(self):\n return '\\n'.join(['M({})={}'.format(p.name, p.M) for p in self.P... | [
"0.51409286",
"0.50731665",
"0.50231826",
"0.49108234",
"0.48673972",
"0.4861895",
"0.48246044",
"0.48213902",
"0.4819359",
"0.4811084",
"0.47524574",
"0.47146547",
"0.4714585",
"0.4713504",
"0.47094056",
"0.46955222",
"0.4657899",
"0.46380806",
"0.46370494",
"0.46309257",
"0... | 0.7829792 | 0 |
Check str of Submission model. | async def test_str(
submission_fixture: Submission,
) -> None:
AssertThat(str(submission_fixture)).IsInstanceOf(str)
AssertThat(str(submission_fixture)).IsEqualTo(submission_fixture.url) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_submission_model_str(self):\n cattle = mommy.make(\n 'main.Task',\n name='Cattle Price')\n submission = mommy.make(\n 'main.Submission',\n task=cattle,\n _fill_optional=['user', 'comment', 'submission_time'])\n expected = \"Cattle... | [
"0.7059866",
"0.62975836",
"0.6151616",
"0.61028385",
"0.6042036",
"0.6003411",
"0.5991225",
"0.59581923",
"0.5912117",
"0.5893448",
"0.5867347",
"0.5861611",
"0.58457726",
"0.58284163",
"0.5810691",
"0.5804451",
"0.5799303",
"0.5771318",
"0.57530624",
"0.5749821",
"0.574816"... | 0.67675114 | 1 |
Default builder context without features. | def default_context(project_name: str) -> None:
return BuilderContext(
project_name=project_name,
kube_name=project_name.replace("_", "-"),
project_description="Generated by pytest.",
ci_type=CIType.none,
db=DatabaseType.none,
db_info=DB_INFO[DatabaseType.none],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getBuilder():",
"def build(self) -> cern.lsa.domain.settings.ContextSettings:\n ...",
"def get_dummy_context():\n context = util.DotDict()\n context.elasticSearchHostname = \"\"\n context.elasticSearchPort = 9200\n context.platforms = (\n {\n \"id\": \"windows\",\n ... | [
"0.66999394",
"0.6211641",
"0.62057453",
"0.6149984",
"0.59577477",
"0.591246",
"0.591246",
"0.5912228",
"0.58951634",
"0.58951634",
"0.58951634",
"0.58951634",
"0.58951634",
"0.58951634",
"0.5883314",
"0.5875144",
"0.58420306",
"0.582237",
"0.5786626",
"0.575766",
"0.5714654... | 0.71017975 | 0 |
Change directory to generator_start_dir. | def default_dir(generator_start_dir: str) -> None:
yield
cwd = os.getcwd()
if cwd != generator_start_dir:
os.chdir(generator_start_dir) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generator_start_dir() -> str:\n old_cwd = os.getcwd()\n newpath = tempfile.mkdtemp()\n os.chdir(newpath)\n try:\n yield newpath\n finally:\n os.chdir(old_cwd)\n shutil.rmtree(newpath, ignore_errors=True)",
"def setup(self, newdir=None):\n if not os.path.exists(self.... | [
"0.7866557",
"0.62242794",
"0.61990684",
"0.617797",
"0.6177548",
"0.6098702",
"0.60680014",
"0.60668284",
"0.5981352",
"0.5979372",
"0.5947241",
"0.5925714",
"0.5915247",
"0.5878447",
"0.5877666",
"0.58542806",
"0.583494",
"0.58293223",
"0.5808327",
"0.5800286",
"0.5794496",... | 0.7948314 | 0 |
returns the first word in a given text. | def first_word(text: str) -> str:
import string
# it's deleting first not letter strings
start = 0
for element in text:
if element in (" ", ",", ".", "'"):
start += 1
elif element in (string.ascii_uppercase + string.ascii_lowercase):
break
text = text[start:l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_word(text: str) -> str:\n # answer = []\n # answer=text.split(\" \", maxsplit=1)\n # import re\n # re.sub(r'a', 'b', 'banana')\n\n answer_wrk = re.search(r\"[a-zA-z\\']+\", text)\n answer = answer_wrk.group(0)\n\n return answer",
"def first_word(text):\n # your code here\n sp... | [
"0.8146144",
"0.8141208",
"0.7967539",
"0.7401317",
"0.7396188",
"0.7192831",
"0.714187",
"0.66818404",
"0.66556394",
"0.65835834",
"0.65610653",
"0.6507425",
"0.6431512",
"0.6374773",
"0.6374773",
"0.63654155",
"0.6336063",
"0.6329843",
"0.6294769",
"0.6290436",
"0.625327",
... | 0.83027816 | 0 |
Create a new AtramhasisProvider | def __init__(self, metadata, **kwargs):
if 'subject' not in metadata:
metadata['subject'] = []
if 'uri' not in metadata:
log.warning(
"AtramhasisProvider: 'uri' is not present in the metadata. "
"This will result in a http call to fetch the concept... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_attestation(attestation: Attestation):\n pass",
"def alpaca_create(self, keyname = \"ALPACA_API_KEY\", secret = \"ALPACA_SECRET_KEY\"):\n aak = os.getenv(keyname)\n ask = os.getenv(secret)\n if type(aak) is not str | type(aak) is not str:\n raise Exception(\"Could no... | [
"0.52555776",
"0.5254564",
"0.52526224",
"0.5233139",
"0.50061494",
"0.49999845",
"0.4925371",
"0.48999807",
"0.4887252",
"0.4868984",
"0.48582995",
"0.48151788",
"0.48077402",
"0.47774965",
"0.47251567",
"0.47028697",
"0.46956468",
"0.46650037",
"0.46495956",
"0.46471313",
"... | 0.60222864 | 0 |
Recupera todas as contas em aberto das igrejas | def pegar_contas_igrejas():
erros = []
contas = []
cpfl = CPFL()
for igreja, instalacao in INSTALACOES.items():
try:
with logging(igreja) as finish:
novas_contas = cpfl.recuperar_contas_abertas(CNPJ, instalacao)
for conta in novas_contas:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def countering():\r\n return []",
"def encontrar_mejor_sitio(ubicaciones):\n\ttorretas_adicionales = ubicaciones.count(\"t\") # obtengo cuantas t (torretas adicionales) hay en ubicaciones\n\tif torretas_adicionales == 0:\n\t\tprint \"Posicion: 5\"\n\tif torretas_adicionales == 4:\n\t\tprint \"Posicion: \",\n\... | [
"0.6024232",
"0.5778898",
"0.5772468",
"0.56903213",
"0.56899667",
"0.5653988",
"0.5653988",
"0.55774236",
"0.5563019",
"0.55446196",
"0.55063593",
"0.54217356",
"0.5399272",
"0.5393137",
"0.53357404",
"0.5330091",
"0.53291875",
"0.53227985",
"0.52933735",
"0.5261711",
"0.524... | 0.63868624 | 0 |
Converts grib files to netcdf using HRRR forecast data and the variables required by the SMRF. Uses the wgrib2 command to identify variable names and uses that to filter the output from the commandline. | def grib2nc(f_hrrr, output=None, external_logger=None):
start = time.time()
if external_logger == None:
fmt = "%(levelname)s: %(msg)s"
log = logging.getLogger(__name__)
coloredlogs.install(logger=log, fmt=fmt)
msg = "GRIB2NC Converter Utility"
log.info(msg)
log.info("=" * len(msg))
# criteria dictionary ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hourly_grib2_to_netcdf(grib_file, grib_source, nc_file, nc_var_name,\n grib_var_name, grib_level, cache_size=100,\n initial_year=1979, overwrite_nc_units=None,\n include_analysis=True,\n nc_format='NETCDF4')... | [
"0.6853723",
"0.6487569",
"0.6329581",
"0.6090967",
"0.56164694",
"0.5534598",
"0.5456288",
"0.53535604",
"0.52977234",
"0.5225581",
"0.5223431",
"0.519277",
"0.5141454",
"0.51206857",
"0.5117262",
"0.50898886",
"0.508972",
"0.5078878",
"0.5070577",
"0.50090307",
"0.49965036"... | 0.7377985 | 0 |
Replace contractions in string of text | def replace_contractions(text):
return contractions.fix(text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_contractions(text):\r\n return contractions.fix(text)",
"def _replace_contractions(text):\n return contractions.fix(text)",
"def replaceContractions(self, text):\n\t\treturn contractions.fix(text)",
"def replace_contractions(self):\n self.text = contractions.fix(self.text)\n r... | [
"0.8687263",
"0.8606106",
"0.8100211",
"0.75796664",
"0.7554637",
"0.73812336",
"0.72393143",
"0.71252644",
"0.6733126",
"0.6524883",
"0.6449502",
"0.6409592",
"0.64059746",
"0.6365393",
"0.6314563",
"0.6309385",
"0.6151162",
"0.61502606",
"0.61313903",
"0.61110896",
"0.61059... | 0.8611583 | 1 |
Only return programs with aids. | def has_aids(self):
return self.exclude(aids=None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def program(cls, program):\n search_str = ArtePlus7.PROGRAMS[program]\n all_programs = cls.search(search_str)\n programs = [p for p in all_programs if p.name == program]\n return programs",
"def extract_programs():\n if settings.XPRO_CATALOG_API_URL:\n return requests.get(se... | [
"0.62694216",
"0.5741981",
"0.56935924",
"0.5627908",
"0.56089944",
"0.5581919",
"0.5562044",
"0.5484791",
"0.54173875",
"0.53707904",
"0.53661776",
"0.53409916",
"0.53327256",
"0.5318837",
"0.5258225",
"0.5221538",
"0.5221057",
"0.52003723",
"0.5185413",
"0.51680654",
"0.514... | 0.59520566 | 1 |
Only return programs with a logo. | def has_logo(self):
return self.exclude(models.Q(logo="") | models.Q(logo=None)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logo(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"logo\")",
"def logo(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"logo\")",
"def _orgWithLogoQuery(model, program):\n q = model.all()\n q.filter('scope', program)\n q.filter('status', 'active')\n ... | [
"0.57749265",
"0.57749265",
"0.56826365",
"0.56404835",
"0.56404835",
"0.56404835",
"0.56404835",
"0.5542502",
"0.5531564",
"0.5531564",
"0.5531564",
"0.5393385",
"0.5332547",
"0.5254092",
"0.5242228",
"0.5217577",
"0.5214733",
"0.51957464",
"0.5155629",
"0.5128401",
"0.50329... | 0.59098417 | 0 |
Set the object's slug if it is missing. | def set_slug(self):
if not self.slug:
self.slug = slugify(self.name)[:50] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_slug(self, slug):\n if self.slug is None:\n self.slug = slug",
"def save(self, *args, **kwargs):\n if not self.slug:\n self.slug = self.generate_slug()\n super().save(*args, **kwargs)",
"def save(self, *args, **kwargs):\n if not self.slug:\n ... | [
"0.82838136",
"0.7608521",
"0.7608521",
"0.75689924",
"0.7556534",
"0.74918675",
"0.73224854",
"0.7266315",
"0.7145025",
"0.7014389",
"0.6966631",
"0.68139696",
"0.6707514",
"0.6704849",
"0.6695652",
"0.6694695",
"0.66387",
"0.6633332",
"0.6626626",
"0.6613412",
"0.6583327",
... | 0.79101604 | 1 |
Error Mail Checker and Handler return True if mail was processed, owtherwise False | def process_error_mail(recipient, sender, journal_id):
if recipient in ['', None]:
#: Simpley Error Mail!
#: TODO: error marking...
return True
try:
param = return_path_from_address(recipient)
assert param['message_id'] != ""
assert param['domain'] != ""
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_mail_when_failed(self, body):\r\n pass",
"def postprocess():\n if ERRORS:\n address = 'tamakoshihiroki@gmail.com'\n body = '\\n\\n'.join( ERRORS )\n msg = create_message( body, address )\n send_mail( msg, address )",
"def verify_mail(self):\n raise N... | [
"0.71684676",
"0.69915545",
"0.6529014",
"0.62857515",
"0.6200424",
"0.6169863",
"0.61431986",
"0.6050912",
"0.6026715",
"0.6016107",
"0.59999835",
"0.59469104",
"0.58907336",
"0.57553744",
"0.57525676",
"0.5709628",
"0.57048935",
"0.5676118",
"0.5647386",
"0.5646338",
"0.559... | 0.7448859 | 0 |
call task by name | def call_task_by_name(mod_name, task_name, *args, **kwargs):
m = __import__(mod_name, globals(), locals(), ["*"])
return getattr(m, task_name).delay(*args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calltask(self, name, **vars):\n if name in self._tasks:\n for entry in self._tasks[name]:\n entry.execute(vars)\n else:\n raise Error(\"No such task: {0}\".format(name))",
"def task(self, name):\n pass",
"def process_task(params):\n params['task'... | [
"0.8585335",
"0.7789529",
"0.72249997",
"0.71038425",
"0.69543546",
"0.69214267",
"0.69214267",
"0.69186956",
"0.68981737",
"0.6868687",
"0.6745845",
"0.6649044",
"0.6632027",
"0.659691",
"0.65874046",
"0.65842366",
"0.6553517",
"0.64654744",
"0.6460285",
"0.6419106",
"0.6415... | 0.77990216 | 1 |
Extract single scale patches from the given image. This op is implemented purely in Tensorflow and so may be more memory efficient when only singlescale patches are required. | def extract_patches_single_scale(
patch_size: int,
stride: int,
image_lt: lt.LabeledTensor,
name: str = None,
) -> Tuple[np.ndarray, lt.LabeledTensor]:
with tf.compat.v1.name_scope(name, "extract_patches_single_scale", [image_lt]) as scope:
image_lt = lt.transpose(image_lt, ["batch", "row", "colum... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _extract_patches_and_positions_from_image(\n image, patch_size, patch_stride, hse_grid_size,\n n_crops, h, w,\n c, scale_id, max_seq_len):\n p = tf.image.extract_patches(\n image, [1, patch_size, patch_size, 1], [1, patch_stride, patch_stride, 1],\n [1, 1, 1, 1],\n padding='SAME')\n\n ... | [
"0.6790287",
"0.65466",
"0.6151751",
"0.6099914",
"0.59317386",
"0.5905685",
"0.57604104",
"0.5746815",
"0.573609",
"0.5610079",
"0.56077653",
"0.56040645",
"0.5576093",
"0.5573452",
"0.5562469",
"0.5551167",
"0.5530099",
"0.55173755",
"0.54859334",
"0.5467564",
"0.54598343",... | 0.7401282 | 0 |
Sets the package_id of this PackageNote. | def package_id(self, package_id):
self._package_id = package_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def package_id(self, package_id):\n if package_id is None:\n raise ValueError(\"Invalid value for `package_id`, must not be `None`\") # noqa: E501\n\n self._package_id = package_id",
"def package(self, package):\n\n self._package = package",
"def set_package(self, pkg): ... | [
"0.75330186",
"0.66790247",
"0.6289974",
"0.5844584",
"0.5844584",
"0.5831869",
"0.5829048",
"0.58280915",
"0.5799856",
"0.5799856",
"0.5799856",
"0.5799856",
"0.5799856",
"0.5799856",
"0.5775636",
"0.5762894",
"0.57389355",
"0.5732315",
"0.571768",
"0.57117283",
"0.5708129",... | 0.8552788 | 0 |
Sets the feed_id of this PackageNote. | def feed_id(self, feed_id):
self._feed_id = feed_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_feed(self, feed: None | Feed = None) -> None:\n self.current_feed = feed\n self.refresh()",
"def setID(self, idf):\n self.id = idf",
"def package_id(self, package_id):\n\n self._package_id = package_id",
"def set_id(self, id_):\n\n self.id_ = id_",
"def set_id(... | [
"0.625687",
"0.5923461",
"0.5919375",
"0.5891008",
"0.5732699",
"0.57217383",
"0.55821204",
"0.55821204",
"0.55821204",
"0.55821204",
"0.55821204",
"0.55821204",
"0.55821204",
"0.55821204",
"0.55821204",
"0.55821204",
"0.55821204",
"0.55821204",
"0.55821204",
"0.55821204",
"0... | 0.8309776 | 0 |
Return a logger instance. | def _logger(self) -> logging.Logger:
return logging.getLogger(
type(self).__name__
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_instance():\n if Logger._logger_instance is None:\n Logger()\n return Logger._logger_instance",
"def get_logger():\r\n global logger\r\n \r\n if logger:\r\n return logger\r\n else:\r\n return create_logger()",
"def logger(self) -> logging.Logger:\n ... | [
"0.83598185",
"0.8020046",
"0.7995714",
"0.79763085",
"0.79743767",
"0.78651994",
"0.7845615",
"0.78387433",
"0.7820369",
"0.7789571",
"0.775313",
"0.77197665",
"0.7691047",
"0.76821923",
"0.76750916",
"0.76057553",
"0.75533676",
"0.7547843",
"0.75393784",
"0.7525153",
"0.752... | 0.81544775 | 1 |
Test cases for invalid sign up and sign in. | def test_case2(self):
valid_email = "test2@email.com"
valid_password = "asdasdasd"
valid_firstname = "name1"
valid_familyname = "name2"
valid_gender = "Female"
valid_city = "Testcity"
valid_country = "Testcountry"
# Valid sign up
response = test_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_5_sign_in_functionality_invalid_email_password(self):\n self.log.debug(\"Validate email and password fields are present\")\n self.page.validate_sign_in_window_elements()\n email = \"abc@gmail.com\" #Invalid email id\n password = \"123456\" #Invalid password\n self.log.de... | [
"0.7088148",
"0.6885961",
"0.6880667",
"0.67373586",
"0.6704038",
"0.6618481",
"0.6604394",
"0.65910316",
"0.6590093",
"0.6574882",
"0.65321714",
"0.6514206",
"0.65073717",
"0.6412174",
"0.63692397",
"0.6344882",
"0.6337391",
"0.63259315",
"0.63258",
"0.6323248",
"0.6315085",... | 0.69835126 | 1 |
Upgrade the package if there is a later version available. | def upgrade_if_needed(self, restart = True, dependencies = False):
if self.check():
print "Upgrading %s" % self.pkg
self.upgrade(dependencies)
if restart:
self.restart() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upgrade(self, old_version, new_version):\n pass",
"def upgrade(self):",
"def upgrade(self):",
"def downgrade():\n pass",
"def downgrade():\n pass",
"def downgrade():\n raise NotImplementedError(\"Downgrade is not supported\")",
"def downgrade():\n raise NotImplementedError(\"Downgrade is... | [
"0.723688",
"0.7112298",
"0.7112298",
"0.7022366",
"0.7022366",
"0.7015959",
"0.7015959",
"0.7015959",
"0.69837075",
"0.66312116",
"0.657686",
"0.65517104",
"0.6545114",
"0.6488389",
"0.64031035",
"0.63755894",
"0.63752556",
"0.6303454",
"0.6300192",
"0.62987626",
"0.62968373... | 0.7406573 | 0 |
Restart application with same args as it was started. Does not return | def restart(self):
print "Restarting " + executable + " " + str(argv)
execl(executable, *([executable]+argv)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restart(reason, *args, **kwargs):\n logging.info(\"Restarting: %s\" % reason)\n os.execv(sys.argv[0], sys.argv)",
"def RestartApp(argv_extra):\n\n p = psutil.Process(os.getpid())\n for handler in p.open_files() + p.connections():\n if handler.fd != -1:\n os.close(handler.fd)\n\n... | [
"0.7492682",
"0.7328665",
"0.7202149",
"0.7188887",
"0.7183816",
"0.71728677",
"0.7089019",
"0.70228314",
"0.70211715",
"0.7020362",
"0.69969636",
"0.69169647",
"0.68793124",
"0.68679875",
"0.6858443",
"0.6785412",
"0.67613715",
"0.67178905",
"0.67106485",
"0.66852856",
"0.66... | 0.7907249 | 0 |
analyze the dynamic translation block coverage with qemu | def analyze_dynamic(self, test_input):
# Execute binary with qemu user mode while taking care of libraries
# collect dynamic translation block execution information
# 1. create a named pipe for qemu to write to
self.mkfifo()
# 2. build command and launch QEMU
# cmd = se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_addr_coverage(self):\n logger.info('Generating translation block coverage information')\n\n tb_files = get_tb_files(self.project_path('s2e-last'))\n tb_coverage_files = aggregate_tb_files(tb_files)\n ret = {}\n\n # Get the number of times each address was executed by S2E... | [
"0.5733099",
"0.5684116",
"0.5423686",
"0.53903526",
"0.5295646",
"0.52860355",
"0.5246108",
"0.5194682",
"0.5191534",
"0.51719093",
"0.5146529",
"0.51181334",
"0.51031566",
"0.508765",
"0.50834346",
"0.505631",
"0.50281286",
"0.50224406",
"0.49979833",
"0.4987376",
"0.497487... | 0.6033092 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.