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 |
|---|---|---|---|---|---|---|
Fit `Nvib` harmonic oscillator and `Nrot` hindered internal rotor modes to the provided dimensionless heat capacities `Cvlist` at temperatures `Tlist` in K. This method assumes that there are enough heat capacity points provided that the vibrational frequencies can be fit directly, but the hindered rotors must be combi... | def fitStatmechPseudoRotors(Tlist, Cvlist, Nvib, Nrot, molecule=None):
# Construct the lower and upper bounds for each variable
bounds = []
# Bounds for harmonic oscillator frequencies
for i in range(Nvib):
bounds.append((hoFreqLowerBound, hoFreqUpperBound))
# Bounds for pseudo-hindered rot... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fitStatmechToHeatCapacity(Tlist, Cvlist, Nvib, Nrot, molecule=None):\n\n # You must specify at least 7 heat capacity points to use in the fitting;\n # you can specify as many as you like above that minimum\n if len(Tlist) < 7:\n raise StatmechFitError('You must specify at least 7 heat capacity ... | [
"0.7044471",
"0.6196605",
"0.60360116",
"0.50493073",
"0.50484276",
"0.5042975",
"0.48713553",
"0.47226658",
"0.46531764",
"0.4640844",
"0.46398926",
"0.45862988",
"0.45844907",
"0.45613056",
"0.4558295",
"0.45362642",
"0.4533591",
"0.45092642",
"0.4467235",
"0.44669557",
"0.... | 0.6537572 | 1 |
Return the heat capacity in J/molK at the given set of temperatures `Tlist` in K for the harmonic oscillator with a frequency `freq` in cm^1. | def harmonicOscillator_heatCapacity(T, freq):
x = freq / (0.695039 * T) # kB = 0.695039 cm^-1/K
exp_x = math.exp(x)
one_minus_exp_x = 1.0 - exp_x
return x * x * exp_x / one_minus_exp_x / one_minus_exp_x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getHeatCapacity(self, Tlist):\n\t\treturn _modes.harmonicoscillator_heatcapacity(Tlist, self.frequency) * self.degeneracy",
"def harmonicOscillator_d_heatCapacity_d_freq(T, freq):\n x = freq / (0.695039 * T) # kB = 0.695039 cm^-1/K\n exp_x = math.exp(x)\n one_minus_exp_x = 1.0 - exp_x\n re... | [
"0.7163064",
"0.71257627",
"0.68290627",
"0.6795192",
"0.6786145",
"0.6622097",
"0.64092433",
"0.62078923",
"0.6155763",
"0.60118943",
"0.5884279",
"0.5819744",
"0.5750861",
"0.57141733",
"0.56468594",
"0.5608937",
"0.5543009",
"0.5515287",
"0.5447956",
"0.53431475",
"0.53323... | 0.7431342 | 0 |
Return the first derivative of the heat capacity with respect to the harmonic oscillator frequency in J/molK/cm^1 at the given set of temperatures `Tlist` in K, evaluated at the frequency `freq` in cm^1. | def harmonicOscillator_d_heatCapacity_d_freq(T, freq):
x = freq / (0.695039 * T) # kB = 0.695039 cm^-1/K
exp_x = math.exp(x)
one_minus_exp_x = 1.0 - exp_x
return x * exp_x / one_minus_exp_x / one_minus_exp_x * (2.0 + x + 2.0 * x * exp_x / one_minus_exp_x) * x / freq | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def harmonicOscillator_heatCapacity(T, freq):\n x = freq / (0.695039 * T) # kB = 0.695039 cm^-1/K\n exp_x = math.exp(x)\n one_minus_exp_x = 1.0 - exp_x\n return x * x * exp_x / one_minus_exp_x / one_minus_exp_x",
"def hinderedRotor_d_heatCapacity_d_freq(T, freq, barr):\n x = constants.h * c... | [
"0.66852283",
"0.6590223",
"0.621406",
"0.61375594",
"0.58432394",
"0.5664569",
"0.5585242",
"0.55327094",
"0.5501561",
"0.5434934",
"0.5308666",
"0.5281351",
"0.5243485",
"0.52303797",
"0.5228673",
"0.51834196",
"0.5166179",
"0.51437104",
"0.51344746",
"0.5100388",
"0.508913... | 0.75777584 | 0 |
Return the heat capacity in J/molK at the given set of temperatures `Tlist` in K for the 1D hindered rotor with a frequency `freq` in cm^1 and a barrier height `barr` in cm^1. | def hinderedRotor_heatCapacity(T, freq, barr):
x = constants.h * constants.c * 100. * freq / constants.kB / T
exp_x = math.exp(x)
one_minus_exp_x = 1.0 - exp_x
z = 0.5 * constants.h * constants.c * 100. * barr / constants.kB / T
BB = scipy.special.i1(z) / scipy.special.i0(z)
return x * x * exp_x... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hinderedRotor_d_heatCapacity_d_barr(T, freq, barr):\n z = 0.5 * constants.h * constants.c * 100. * barr / constants.kB / T\n BB = scipy.special.i1(z) / scipy.special.i0(z)\n return z * (1 - 2 * z * BB + BB * BB + 2 * z * BB * BB * BB) * z / barr",
"def hinderedRotor_d_heatCapacity_d_freq(T, freq, ba... | [
"0.6776927",
"0.6629585",
"0.6302823",
"0.6265761",
"0.6249234",
"0.6213433",
"0.61068034",
"0.59889144",
"0.5958544",
"0.59443885",
"0.58387303",
"0.5672785",
"0.5489304",
"0.535626",
"0.5331149",
"0.5270583",
"0.5189233",
"0.5121388",
"0.49093267",
"0.48052287",
"0.47886142... | 0.68888056 | 0 |
Return the first derivative of the heat capacity with respect to the hindered rotor frequency in J/molK/cm^1 at the given set of temperatures `Tlist` in K, evaluated at the frequency `freq` in cm^1 and a barrier height `barr` in cm^1. | def hinderedRotor_d_heatCapacity_d_freq(T, freq, barr):
x = constants.h * constants.c * 100. * freq / constants.kB / T
exp_x = math.exp(x)
one_minus_exp_x = 1.0 - exp_x
return x * exp_x / one_minus_exp_x / one_minus_exp_x * (2 + x + 2 * x * exp_x / one_minus_exp_x) * x / freq | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hinderedRotor_d_heatCapacity_d_barr(T, freq, barr):\n z = 0.5 * constants.h * constants.c * 100. * barr / constants.kB / T\n BB = scipy.special.i1(z) / scipy.special.i0(z)\n return z * (1 - 2 * z * BB + BB * BB + 2 * z * BB * BB * BB) * z / barr",
"def hinderedRotor_heatCapacity(T, freq, barr):\n ... | [
"0.71285737",
"0.6478923",
"0.6444968",
"0.5749547",
"0.56793684",
"0.5572982",
"0.54065436",
"0.53827864",
"0.5258031",
"0.5257182",
"0.52520823",
"0.519607",
"0.50965065",
"0.49622813",
"0.49369383",
"0.49278474",
"0.48772767",
"0.4856664",
"0.48498905",
"0.48304605",
"0.47... | 0.7382771 | 0 |
Return the first derivative of the heat capacity with respect to the hindered rotor frequency in J/molK/cm^1 at the given set of temperatures `Tlist` in K, evaluated at the frequency `freq` in cm^1 and a barrier height `barr` in cm^1. | def hinderedRotor_d_heatCapacity_d_barr(T, freq, barr):
z = 0.5 * constants.h * constants.c * 100. * barr / constants.kB / T
BB = scipy.special.i1(z) / scipy.special.i0(z)
return z * (1 - 2 * z * BB + BB * BB + 2 * z * BB * BB * BB) * z / barr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hinderedRotor_d_heatCapacity_d_freq(T, freq, barr):\n x = constants.h * constants.c * 100. * freq / constants.kB / T\n exp_x = math.exp(x)\n one_minus_exp_x = 1.0 - exp_x\n return x * exp_x / one_minus_exp_x / one_minus_exp_x * (2 + x + 2 * x * exp_x / one_minus_exp_x) * x / freq",
"def hinderedR... | [
"0.73835194",
"0.64815336",
"0.64464134",
"0.57504225",
"0.5682341",
"0.557329",
"0.54102564",
"0.53866494",
"0.5260977",
"0.5259946",
"0.5251516",
"0.5194793",
"0.5095279",
"0.49629185",
"0.4936573",
"0.49281287",
"0.48756847",
"0.48563507",
"0.48486865",
"0.4834765",
"0.479... | 0.71289545 | 1 |
compute the n period relative strength indicator | def relative_strength(prices, n):
deltas = np.diff(prices)
seed = deltas[:n+1] # takes the last 1 price differences? 12 market days?
up = seed[seed>=0].sum()/n
down = -seed[seed<0].sum()/n
rs = up/down
rsi = np.zeros_like(prices)
rsi[:n] = 100. - 100./(1.+rs)
for i in range(n, len(pric... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculateRelativeStrengthIndex(self, series, interval=14):\n\n if not isinstance(series, pd.Series):\n raise TypeError('Pandas Series required.')\n\n if not isinstance(interval, int):\n raise TypeError('Interval integer required.')\n\n if(len(series) < interval):\n ... | [
"0.62993854",
"0.6251063",
"0.62505263",
"0.61611295",
"0.6143028",
"0.5975309",
"0.5954106",
"0.58517736",
"0.5804187",
"0.57787424",
"0.57643014",
"0.5751086",
"0.5728138",
"0.5679147",
"0.56747293",
"0.5648136",
"0.56302524",
"0.56128484",
"0.55958307",
"0.556552",
"0.5563... | 0.66415566 | 0 |
relative if true, the exclusion of the ratios (relative to the inputs given) are plotted. If False, these ratios are multiplied by the SM cross sections and branching ratios into gamma gamma inputIsAbs is a list (set) of file names which should be treated as if they had ABSOLUTE limits on cross sections rather than rel... | def makePlot(csvFnames, relative, includeExpected = True, fermiophobic = None, ymax = None, inputIsAbs = None, drawXsectBR = False,
minMass = None,
maxMass = None,
plotLog = False
):
#--------------------
# read the files
#--------------------... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plotBatch(inp,output='spectra_plot.pdf',comparisons=None,classify=False,normalize=False,normrange=[0.9,1.4],layout=[2,2],basecolors=['k','m'],legend=[],fontscale=0.7,classify_kwargs={},plot_kwargs={},**kwargs):\n\n# alt keyword check\n for k in ['file','filename']: \n if kwargs.get(k,'') != '': outpu... | [
"0.5534918",
"0.515236",
"0.51322854",
"0.49179512",
"0.48812607",
"0.48483542",
"0.4839429",
"0.47949347",
"0.47881106",
"0.47665024",
"0.47452495",
"0.4722007",
"0.47154492",
"0.46393847",
"0.462126",
"0.46191898",
"0.460472",
"0.46012208",
"0.4596538",
"0.4591982",
"0.4580... | 0.60177034 | 0 |
Test the CommandList class | def test_CommandList():
from paradrop.confd.command import CommandList
clist = CommandList()
clist.append(20, "b")
clist.append(20, "c")
clist.append(10, "a")
commands = list(clist.commands())
assert commands == ["a", "b", "c"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_arg_parser_list(self):\n args = self.parser.parse_args(['list'])\n self.assertEqual(args.command, 'list')",
"def test_listCommand(self):\n acli = ArmiCLI()\n\n origout = sys.stdout\n try:\n out = io.StringIO()\n sys.stdout = out\n acli.... | [
"0.7797336",
"0.7349881",
"0.72588724",
"0.72235614",
"0.72235614",
"0.7143625",
"0.71298486",
"0.70965886",
"0.68910056",
"0.68389577",
"0.68290025",
"0.6811658",
"0.67939836",
"0.6771567",
"0.6757199",
"0.6725292",
"0.669489",
"0.6669298",
"0.65990645",
"0.6597851",
"0.6595... | 0.81857985 | 0 |
Test the KillCommand class | def test_KillCommand(execute):
from paradrop.confd.command import KillCommand
# Test with a numeric pid.
command = KillCommand(12345)
assert command.getPid() == 12345
expected = ["kill", "12345"]
command.execute()
assert execute.called_once_with(expected)
execute.reset_mock()
pid... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_kill(self):\n A = ConwayAgent(23, True)\n self.assertTrue(A.status() == 1)\n A.kill()\n self.assertTrue(A.status() == 0)",
"def remote_kill():",
"def test_build_kill_command(self):\n actual_result = IperfKillCommandBuilder(SERVER_USER)\\\n .set_ip_address(... | [
"0.7480365",
"0.71652985",
"0.6940902",
"0.6931124",
"0.6846783",
"0.6776122",
"0.6691397",
"0.6687754",
"0.6556142",
"0.6425788",
"0.64247656",
"0.6313827",
"0.6313541",
"0.6313541",
"0.63063496",
"0.62784046",
"0.6265679",
"0.6265679",
"0.62479097",
"0.6243085",
"0.6227352"... | 0.7495398 | 0 |
A hook to start the Selenium Server provided with SeleniumLibrary. `logfile` must be either an opened file (or filelike object) or None. If not None, Selenium Server log will be written to it. `jarpath` must be either the absolute path to the seleniumserver.jar or None. If None, the jar file distributed with the librar... | def start_selenium_server(logfile=None, jarpath=None, *params):
if not subprocess:
raise RuntimeError('This function requires `subprocess` module which '
'is available on Python/Jython 2.5 or newer.')
cmd = _server_startup_command(jarpath, *params)
try:
subprocess.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_selenium_server(self, *params):\n params = ('-port', str(self._server_port)) + params\n logpath = os.path.join(self._get_log_dir(), 'selenium_server_log.txt')\n self._selenium_log = open(logpath, 'w')\n start_selenium_server(self._selenium_log, self._jar_path, *params)\n ... | [
"0.6576157",
"0.59147495",
"0.551453",
"0.5020369",
"0.4867105",
"0.48326635",
"0.48120183",
"0.48082626",
"0.4748094",
"0.4661346",
"0.4636292",
"0.46114662",
"0.4580532",
"0.4558185",
"0.45508748",
"0.45206273",
"0.45122933",
"0.44885132",
"0.4487213",
"0.44591105",
"0.4454... | 0.81625164 | 0 |
Shuts down the Selenium Server. `host` and `port` define where the location of Selenium Server. Does not fail even if the Selenium Server is not running. | def shut_down_selenium_server(host='localhost', port=4444):
try:
selenium(host, port, '', '').shut_down_selenium_server()
except socket.error:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop_selenium_server(self):\n shut_down_selenium_server(self._server_host, self._server_port)\n self._selenium = NoBrowserOpen()\n if self._selenium_log:\n self._selenium_log.close()",
"def shutdown(self):\n # TODO: Build a certificate chain so we can verify our localho... | [
"0.6310834",
"0.6110192",
"0.6078012",
"0.59138757",
"0.57922274",
"0.5763965",
"0.56827766",
"0.566105",
"0.55425066",
"0.55398613",
"0.5532105",
"0.5505663",
"0.54810226",
"0.5456112",
"0.5435537",
"0.5409633",
"0.5404485",
"0.5392909",
"0.53838885",
"0.53706366",
"0.532538... | 0.8380863 | 0 |
SeleniumLibrary can be imported with optional arguments. `timeout` is the default timeout used to wait for page load actions. It can be later set with `Set Selenium Timeout` `server_host` and `server_port` are used to connect to Selenium Server. Browsers opened with this SeleniumLibrary instance will be attached to tha... | def __init__(self, timeout=5.0, server_host='localhost', server_port=4444,
jar_path=None, run_on_failure='Capture Screenshot'):
self._cache = utils.ConnectionCache()
self._selenium = NoBrowserOpen()
self.set_selenium_timeout(timeout or 5.0)
self._server_host, self._serve... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, driver_path: str = None, waiter_timeout: int = 3, options: List[str] = None):\n\n # selecting driver\n if not driver_path:\n driver = webdriver.Firefox\n driver_options = FireFoxOptions()\n else:\n driver = webdriver.Chrome\n drive... | [
"0.5883255",
"0.5759221",
"0.57567716",
"0.5650392",
"0.5649762",
"0.55207306",
"0.5444826",
"0.53997815",
"0.535544",
"0.5268799",
"0.5228582",
"0.5209584",
"0.5167454",
"0.5134206",
"0.50916547",
"0.50906485",
"0.505967",
"0.5057035",
"0.50250274",
"0.49927777",
"0.49799502... | 0.5961083 | 0 |
Starts the Selenium Server provided with SeleniumLibrary. `params` can contain additional command line options given to the Selenium Server. This keyword uses some command line options | def start_selenium_server(self, *params):
params = ('-port', str(self._server_port)) + params
logpath = os.path.join(self._get_log_dir(), 'selenium_server_log.txt')
self._selenium_log = open(logpath, 'w')
start_selenium_server(self._selenium_log, self._jar_path, *params)
self._ht... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_selenium_server(logfile=None, jarpath=None, *params):\n if not subprocess:\n raise RuntimeError('This function requires `subprocess` module which '\n 'is available on Python/Jython 2.5 or newer.')\n cmd = _server_startup_command(jarpath, *params)\n try:\n ... | [
"0.62242675",
"0.58627564",
"0.56516945",
"0.56402934",
"0.56345683",
"0.56059575",
"0.56059575",
"0.5513187",
"0.5233649",
"0.5220939",
"0.51877004",
"0.51692015",
"0.51691693",
"0.5165994",
"0.51010007",
"0.50910467",
"0.50774854",
"0.5061027",
"0.50559413",
"0.5016454",
"0... | 0.6509325 | 0 |
Stops the selenium server (and closes all browsers). | def stop_selenium_server(self):
shut_down_selenium_server(self._server_host, self._server_port)
self._selenium = NoBrowserOpen()
if self._selenium_log:
self._selenium_log.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop_browser(self):\n self.driver.quit()",
"def shut_down_selenium_server(host='localhost', port=4444):\n try:\n selenium(host, port, '', '').shut_down_selenium_server()\n except socket.error:\n pass",
"def __exit__(self, exc_type, exc_val, exc_tb):\n self.server.stop()\n ... | [
"0.7995364",
"0.7863133",
"0.7835495",
"0.74924666",
"0.7464111",
"0.7453941",
"0.7446109",
"0.7424754",
"0.7343588",
"0.73252535",
"0.7277652",
"0.72618127",
"0.7260277",
"0.7200706",
"0.71930265",
"0.71509975",
"0.7085253",
"0.70522535",
"0.7039435",
"0.7002137",
"0.699096"... | 0.83716977 | 0 |
Sets the delay that is waited after each Selenium command. This is useful mainly in slowing down the test execution to be able to view the execution. `seconds` may be given in Robot Framework time format. Returns the previous speed value. | def set_selenium_speed(self, seconds):
old = self._selenium.get_speed()
seconds = str(int(utils.timestr_to_secs(seconds)*1000))
self._selenium.set_speed(seconds)
return utils.secs_to_timestr(float(old)/1000) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delay(seconds):\n\n # Perform the delay\n time.sleep(seconds)",
"def set_selenium_timeout(self, seconds):\n timeout = utils.timestr_to_secs(seconds)\n old = getattr(self, '_timeout', timeout)\n self._timeout = timeout\n self._selenium.set_timeout(timeout * 1000)\n ret... | [
"0.66323715",
"0.6297846",
"0.6280223",
"0.62300897",
"0.6206175",
"0.6159071",
"0.6082828",
"0.60776395",
"0.60160977",
"0.60102314",
"0.59985185",
"0.59399515",
"0.5932031",
"0.5910213",
"0.5898481",
"0.58874804",
"0.5863831",
"0.5814787",
"0.5781439",
"0.5781439",
"0.56741... | 0.6863085 | 0 |
Calls a method in the Selenium remote control API directly. This keyword can be used if some functionality provided by Selenium is not yet exposed as a keyword. `method_name` is the name of the method to call in the Selenium API and `args` specify the arguments it expects. The keyword first tries to find a method in Se... | def call_selenium_api(self, method_name, *args):
try:
method = getattr(self._selenium, method_name)
except AttributeError:
method = lambda *args: self._selenium.do_command(method_name, args)
return method(*args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _call_command_method(self, name, original_method, args, kwargs):\n if threadprop.current_controller() is not self:\n action=self._direct_comm_call_action\n if action==\"warning\":\n if name not in self._command_warned:\n print(\"Warning: direct cal... | [
"0.64679945",
"0.6191388",
"0.6156052",
"0.614689",
"0.6126066",
"0.61218405",
"0.6005276",
"0.59827995",
"0.59674746",
"0.5966414",
"0.5953731",
"0.5952385",
"0.5854593",
"0.576358",
"0.5734514",
"0.5709739",
"0.5668814",
"0.56597054",
"0.5618796",
"0.55931056",
"0.5582841",... | 0.7929701 | 0 |
Adds a custom location strategy. `strategy_name` is the name of the strategy; a prefix used when addressing an element. `function_definition` is the JavaScript that will be called. It must return a DOM reference, an array with DOM references, or null. Together with the modified seleniumserver.jar it can provide a new m... | def add_location_strategy(self, strategy_name, function_definition):
self._locator_parser.add_strategy(strategy_name)
self._selenium.add_location_strategy(strategy_name, function_definition) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strategy(func):\n strategies.append(func)\n return func",
"def strategy(strategy_name: str):\r\n def wrapper(finder_class):\r\n global strategies\r\n strategies[strategy_name] = finder_class\r\n return finder_class\r\n return wrapper",
"def _apply_hooks(\n context: HookC... | [
"0.5778675",
"0.5589892",
"0.47768068",
"0.4705223",
"0.46349427",
"0.45650652",
"0.44619638",
"0.44110903",
"0.43347523",
"0.42556694",
"0.42554522",
"0.4228382",
"0.41904864",
"0.41884336",
"0.41832274",
"0.41638365",
"0.4158864",
"0.4145258",
"0.41342977",
"0.41133204",
"0... | 0.85643756 | 0 |
Squash deeply nested dictionary. | def squash(data, parent_key="", sep="."):
items = []
for k, v in data.items():
k = str(k)
if k[0] == "_":
k = k[1:]
new_key = parent_key + sep + k if parent_key else k
if isinstance(v, collections.abc.MutableMapping):
items.extend(squash(v, new_key, sep=s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursive_squeeze(dictlike):\n out = {}\n for k, v in dictlike.items():\n if isinstance(v, dict):\n out[k] = recursive_squeeze(v)\n else:\n out[k] = np.squeeze(v)\n return out",
"def unflatten(\n d: Dict[str, Any],\n base: Dict[str, Any] = None,\n) -> Dict[s... | [
"0.6798054",
"0.6370052",
"0.63272715",
"0.62804824",
"0.6247005",
"0.6229685",
"0.6208201",
"0.62053543",
"0.6178594",
"0.61608326",
"0.6072516",
"0.6069942",
"0.5972645",
"0.5956857",
"0.59553653",
"0.5934359",
"0.59289074",
"0.59246",
"0.5923879",
"0.5918683",
"0.5888782",... | 0.6701361 | 1 |
Logarithm of the hyperbolic cosine of the prediction error. `log(cosh(x))` is approximately equal to `(x 2) / 2` for small `x` and to `abs(x) log(2)` for large `x`. This means that 'logcosh' works mostly like the mean squared error, but will not be so strongly affected by the occasional wildly incorrect prediction. | def logcosh(y_true, y_pred):
def _logcosh(x):
return x + nn.softplus(-2. * x) - math_ops.log(2.)
return K.mean(_logcosh(y_pred - y_true), axis=-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_cosh(y_true, y_pred):\n y_pred = tensor_conversion.convert_to_tensor_v2_with_dispatch(y_pred)\n y_true = math_ops.cast(y_true, y_pred.dtype)\n\n def _logcosh(x):\n return x + math_ops.softplus(-2. * x) - math_ops.cast(\n math_ops.log(2.), x.dtype)\n\n return backend.mean(_logcosh(y_pred - y_t... | [
"0.76132387",
"0.72645205",
"0.70176494",
"0.6731372",
"0.6226951",
"0.62121165",
"0.6074388",
"0.6073056",
"0.59627014",
"0.5937668",
"0.5929191",
"0.5901009",
"0.58072233",
"0.5728377",
"0.5656887",
"0.5649234",
"0.5644657",
"0.5626796",
"0.56044716",
"0.55885035",
"0.55826... | 0.74146074 | 1 |
Returns the pascal triangle of n. | def pascal_triangle(n):
if n <= 0:
return []
l = [[0 for x in range(i + 1)] for i in range(n)]
l[0] = [1]
for i in range(1, n):
l[i][0] = 1
for j in range(1, i + 1):
if j < len(l[i - 1]):
l[i][j] = l[i - 1][j - 1] + l[i - 1][j]
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_pascal_triangle(self, n):\r\n if n == 0:\r\n return list()\r\n\r\n return [self.gen_triangle_level(i)\r\n for i\r\n in range(1, n + 1, 1)]",
"def pascal_triangle(n):\n if n <= 0:\n return []\n\n a = [[1 for i in range(1, j + 1)] for j... | [
"0.83876556",
"0.8313631",
"0.8303543",
"0.82191485",
"0.8042562",
"0.8002575",
"0.7965688",
"0.7950681",
"0.7875324",
"0.7869357",
"0.78521544",
"0.7814328",
"0.7648985",
"0.7577198",
"0.7450272",
"0.7302716",
"0.71677047",
"0.7041317",
"0.6824642",
"0.6618727",
"0.659417",
... | 0.83408237 | 1 |
Read XYZ and visualisation files from simulation | def read_simulation_files(self):
# Check if simulation files exist in current directory, if not kill process
if not os.path.isfile('{}.xyz'.format(self.prefix)):
print('Cannot find simulation file "{}.xyz"'.format(self.prefix))
sys.exit()
if not os.path.isfile('{}_vis2d.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_simulation_results(self,\n fname_sims, \n fname_pareto = None, \n fname_cull = None):\n\n \n self.fname_sims = fname_sims\n self.__read_file(fname_sims, 'sim_results')\n \n if fname_pareto is no... | [
"0.61848754",
"0.6042058",
"0.59669006",
"0.59361804",
"0.58964205",
"0.5878065",
"0.58193845",
"0.57807654",
"0.57697374",
"0.57643694",
"0.5762156",
"0.5759421",
"0.57102454",
"0.56983227",
"0.56967455",
"0.569428",
"0.56905067",
"0.5686337",
"0.56723523",
"0.5671769",
"0.5... | 0.74568313 | 0 |
Visualise particles and polygons | def visualise(self):
# Initialise figure
params = {"figure.figsize": (5, 5)}
pylab.rcParams.update(params)
self.fig = plt.figure()
self.ax = self.fig.add_subplot(111)
# Add particles if selected
print(self.crds)
cmap=cm.get_cmap('coolwarm')
norm=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visualize(title, particles):\n\n plt.figure(figsize=(10,10))\n plt.title(\"Best configuration for \" + str(len(particles)) + \" particles\", size=25)\n plt.xlabel(\"xcoordinate\", size=18)\n plt.ylabel(\"ycoordinate\", size=18)\n\n plt.xticks(size=13)\n plt.yticks(size=13)\n\n circle = plt... | [
"0.717661",
"0.68778163",
"0.67623657",
"0.65606654",
"0.65092915",
"0.64102745",
"0.6362865",
"0.63186747",
"0.6282361",
"0.6227061",
"0.6184886",
"0.616295",
"0.61177635",
"0.6107491",
"0.6087164",
"0.6042589",
"0.59876037",
"0.59707433",
"0.5968525",
"0.5959219",
"0.594656... | 0.72570527 | 0 |
When called with L{None}, L{to_xml} returns a L{Deferred} that fires with C{b""}. | def test_none(self):
self.assertEqual(b"", self.successResultOf(to_xml(None))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_xml(self):\n with io.StringIO() as string:\n string.write(ET.tostring(self.root, encoding=\"unicode\"))\n return string.getvalue()",
"def xml_string(self):\r\n if self._xml_string is not None:\r\n return self._xml_string\r\n\r\n return etree.tostring(... | [
"0.6010409",
"0.5807119",
"0.5803181",
"0.57231146",
"0.5688771",
"0.5660354",
"0.54970235",
"0.5462216",
"0.54385936",
"0.538115",
"0.53393245",
"0.5326203",
"0.5314152",
"0.53080094",
"0.5306955",
"0.52890134",
"0.52495795",
"0.5163723",
"0.5145049",
"0.513027",
"0.5113245"... | 0.70309347 | 0 |
in this view the teacher can create a forum post | def teacher_forum_create(request):
# Deleting admin-typed user session
# Deleting programmer-typed-user session
# Get the current users
current_basic_user = get_current_user(request, User, ObjectDoesNotExist)
current_basic_user_profile = get_current_user_profile(
request,
User,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(self):\n teacher = self.request.get(\"teacher\")\n student = self.request.get(\"student\")\n lessondate = self.request.get(\"lessondate\")\n reason = self.request.get(\"reason\")\n comment = self.request.get(\"comment\")\n\n if teacher and student and lessondate a... | [
"0.7329339",
"0.7162002",
"0.70594895",
"0.7003851",
"0.6994737",
"0.6979558",
"0.6978259",
"0.691917",
"0.6845622",
"0.68156683",
"0.67997193",
"0.6753117",
"0.67289805",
"0.6726166",
"0.67195654",
"0.66782594",
"0.66578925",
"0.6632889",
"0.6628704",
"0.6607489",
"0.660156"... | 0.8074095 | 0 |
in this view the teacher can update their own posts | def teacher_forum_update(request, post_id):
# Deleting admin-typed user session
# Deleting programmer-typed-user session
# Get the current users
current_basic_user = get_current_user(request, User, ObjectDoesNotExist)
current_basic_user_profile = get_current_user_profile(
request,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_update():\n\n\n user_id = session['user_id']\n post = request.form.get('post')\n\n Update.add_update(user_id, post)\n\n return \"Updated Post\"",
"def post(self):\n subject = self.request.get('subject')\n content = self.request.get('post_content')\n post_id = self.reques... | [
"0.719283",
"0.71187025",
"0.6917328",
"0.69051486",
"0.6806218",
"0.6707744",
"0.65740657",
"0.6540123",
"0.64509684",
"0.6392218",
"0.63798857",
"0.63631964",
"0.636004",
"0.6351142",
"0.6350981",
"0.63290304",
"0.63229775",
"0.6306676",
"0.6287355",
"0.6259736",
"0.6248741... | 0.7201709 | 0 |
Verify that an empty Project instance can be created | def test_empty(self):
p = Project()
assert isinstance(p, "Project")
assert len(p.samples) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_empty_project_create(self):\n\n responses.add(\n responses.POST,\n self.host + \"/manager\",\n json={'message': \"Project name cannot be empty.\", 'status':\"error\"},\n status=200\n )\n\n with self.assertRaises(CreateError):\n se... | [
"0.7565686",
"0.7472565",
"0.7472565",
"0.7472565",
"0.7403371",
"0.718804",
"0.71662986",
"0.7149225",
"0.71124834",
"0.7100387",
"0.7081178",
"0.7073791",
"0.7022151",
"0.70001334",
"0.6987323",
"0.69563067",
"0.69153684",
"0.688426",
"0.68389845",
"0.6823242",
"0.68211466"... | 0.7878026 | 0 |
Get rss data from url, print single entry to show latest news, else give index number | def get_rss(limit):
rss_data = feedparser.parse(URL)
if limit == 1:
title = rss_data.entries[0].title
link = rss_data.entries[0].link
rss_print(title, link)
else:
for i in range(0, limit):
title = rss_data.entries[i].title
link = rss_data.entries[i].li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_news(url):\r\n \r\n # parse RSS feed into list of dictionaries\r\n feed = feedparser.parse(url)\r\n\r\n # no RSS feed articles for url\r\n if len(feed['entries']) == 0:\r\n return []\r\n \r\n # get first ten articles from the RSS feed\r\n news = []\r\n i = 0\r\n while T... | [
"0.75352377",
"0.6732173",
"0.66765153",
"0.665058",
"0.65504193",
"0.6381726",
"0.6367431",
"0.63618726",
"0.63228035",
"0.6274171",
"0.6259605",
"0.6249335",
"0.6235714",
"0.623111",
"0.62301534",
"0.6225683",
"0.6224893",
"0.6210909",
"0.6184807",
"0.6138288",
"0.61182076"... | 0.69751287 | 1 |
item cf base contribution score by user | def base_contribute_score():
return 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def score(self):",
"def scoring(self):\n pass",
"def get_contribution_score(self):\n self._extract()\n for key in BitBucketEnum.USER_CONTRIBUTION_MAPPING:\n if key.high >= self.total_no_of_repos >= key.low:\n return BitBucketEnum.USER_CONTRIBUTION_MAPPING[key]\n ... | [
"0.620806",
"0.61869097",
"0.6163936",
"0.61014056",
"0.60496336",
"0.5992737",
"0.5977021",
"0.59710246",
"0.5925449",
"0.59224397",
"0.5915847",
"0.5837098",
"0.58159584",
"0.5804917",
"0.5716641",
"0.5706325",
"0.5704022",
"0.569648",
"0.5693049",
"0.5656052",
"0.5626995",... | 0.66897124 | 0 |
Check if p < alpha | def _result(self, p, alpha):
if p < alpha:
self._verbose('reject H0')
return False
else:
self._verbose('Fail to reject H0')
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pvalue_test(self, alpha=0.01):\n CL = int((1-alpha)*100) # confidence level\n \n if self.p_value < alpha:\n print(\"Null hypothesis rejected at {:d}%CL => distributions are different\".format(CL))\n else:\n print(\"Null hypothesis NOT rejected => distr... | [
"0.6903913",
"0.65936184",
"0.64266586",
"0.6404423",
"0.632386",
"0.617827",
"0.6169871",
"0.6154222",
"0.6103611",
"0.60738355",
"0.6071435",
"0.60705245",
"0.6026349",
"0.6003107",
"0.59858894",
"0.5979116",
"0.5966189",
"0.5961026",
"0.59589374",
"0.59494054",
"0.5945314"... | 0.7522837 | 0 |
Check if samples follow a normal distribution, according to the Shapiro test. In case of two samples, check if both the samples follow a normal distribution. | def check_normality(self,alpha = 0.05):
stat1, p = shapiro(self.x)
if self.y is not None:
stat2, p2 = shapiro(self.y)
if p < alpha:
if self.y is not None:
if p2 < alpha:
self._verbose('x and y do not look Gaussian... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_normality(df, features_to_analyse, p_value_threshold=0.05):\n \n is_normal_threshold = 1 - p_value_threshold\n\n normality_results = pd.DataFrame(data=None, index=['stat','pval'], columns=features_to_analyse)\n for f, feature in enumerate(features_to_analyse):\n try:\n stat,... | [
"0.6643706",
"0.6607907",
"0.65663075",
"0.656181",
"0.64410543",
"0.64410543",
"0.64410543",
"0.6429082",
"0.6350439",
"0.6350439",
"0.6350439",
"0.6209372",
"0.60482424",
"0.6045995",
"0.60372585",
"0.58879375",
"0.5857885",
"0.5827552",
"0.5822744",
"0.57681113",
"0.572109... | 0.7163608 | 0 |
Compare the sample mean to a theoretical value, or compare samples means. If samples follow a normal distribution, the ttest is used if the number of samples is less than n. The ztest, otherwise. If the samples are not normal, the Wilcoxon test is used. | def compare_means(self, value = None, alpha = 0.05, n = 50):
p = None
if self.y is None:
# one sample test
if self.is_normal:
if len(self.x) <= n:
stat, p = ttest_1samp(self.x, value)
else:
stat, p = ztest(s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ztest_mean(self, value=0, alternative=\"two-sided\"):\n tstat = (self.mean - value) / self.std_mean\n # TODO: use outsourced\n if alternative == \"two-sided\":\n pvalue = stats.norm.sf(np.abs(tstat)) * 2\n elif alternative == \"larger\":\n pvalue = stats.norm.s... | [
"0.7094629",
"0.6431837",
"0.6431837",
"0.6431837",
"0.63993895",
"0.6372074",
"0.6372074",
"0.6372074",
"0.6092988",
"0.59103686",
"0.5790642",
"0.57710034",
"0.57710034",
"0.57670575",
"0.57560855",
"0.5721325",
"0.56856143",
"0.56267905",
"0.56255215",
"0.56172353",
"0.557... | 0.7326671 | 0 |
Compare the sample distribution to a given cdf (cumulative distribution function), if one sample is provided. The KolmogorovSmirnov Test is used. Compare the samples distribution, if two samples are provided. In this case, the Chi Square test is used. | def compare_distributions(self, alpha = 0.05, cdf = None, args=(), freq = False):
if freq:
if self.y is not None:
stat, p = chisquare(self.x, f_exp = self.y)
else:
return None
else:
if cdf is not None:
stat, p = kstest(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def f_test(chi1,df1,chi2,df2,red_chi = True):\n\n# if chi1/df1 > chi2/df2:\n#\tprob = 2. * f.cdf(chi1/df1, chi2/df2, df1, df2)\n# else:\n#\tprob = 2. * f.cdf(chi2/df2, chi1/df1, df2, df1)\n if red_chi:\n\tfval = (chi1/df1) / (chi2/df2)\n else:\n\tfval = chi1 / chi2\n prob = 2. * f.cdf((chi1/df1) / (... | [
"0.7114142",
"0.62854636",
"0.61177313",
"0.61136746",
"0.5970565",
"0.5863553",
"0.585731",
"0.5784674",
"0.5686073",
"0.55763865",
"0.55630934",
"0.5556157",
"0.5546654",
"0.55157024",
"0.55142057",
"0.5466505",
"0.54631937",
"0.5452893",
"0.54494053",
"0.54422474",
"0.5438... | 0.7335901 | 0 |
This function selects num peers from the torrent. If select_seeders is True, then we only select seeders otherwise, we only select leechers. By default we use random.sample, but feel free to implement your own selection system. | def select_people(torrent, select_seeders=True, num=50):
selector = torrent.seeders if select_seeders else torrent.leechers
resp = random.sample(selector, min(num, len(selector)))
return resp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accept_seeders(self, accept_seeds):\n if accept_seeds:\n call = \"d.accepting_seeders.enable\"\n else:\n call = \"d.accepting_seeders.disable\"\n\n m = rtorrent9.rpc.Multicall(self)\n self.multicall_add(m, call)\n\n return m.call()[-1]",
"def select_cl... | [
"0.6207165",
"0.598683",
"0.55595607",
"0.55328155",
"0.54304093",
"0.5372144",
"0.535326",
"0.5268179",
"0.5265857",
"0.52191955",
"0.5192883",
"0.5186847",
"0.5138152",
"0.50706697",
"0.50696266",
"0.5061419",
"0.505665",
"0.50276333",
"0.5012703",
"0.5010171",
"0.5006359",... | 0.8250936 | 0 |
The FNN enc and FNN dec of the Denoiser. | def __init__(self, input_dim):
super(ps_FNNDenoiser, self).__init__()
self._input_dim = input_dim
self.fnn_enc = Linear(self._input_dim, int(self._input_dim / 2))
self.fnn_dec = Linear(int(self._input_dim / 2), self._input_dim)
self.initialize_module() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _encode(self):\n with tf.variable_scope('encoding'):\n self.sep_p_encodes, _ = bilstm_layer(self.p_emb, self.p_length, self.hidden_size)\n tf.get_variable_scope().reuse_variables()\n self.sep_q_encodes, _ = bilstm_layer(self.q_emb, self.q_length, self.hidden_size)\n ... | [
"0.55594534",
"0.5484632",
"0.5475248",
"0.5433192",
"0.53741807",
"0.5338545",
"0.53328925",
"0.5324473",
"0.5303475",
"0.52772224",
"0.5273364",
"0.5268513",
"0.5253051",
"0.5249744",
"0.52083373",
"0.5200783",
"0.51895785",
"0.5175783",
"0.51673234",
"0.5162198",
"0.513767... | 0.64204884 | 0 |
Checks that password is longer than 8 characters and that it contains upper and lowercase letters and at least one number. | def _validatePassword(password):
uppercaseChars = re.search('[A-Z]', password)
lowercaseChars = re.search('[a-z]', password)
if len(password) < 8:
raise Exception("Password must be at lest 8 letters")
elif re.search('[0-9]', password) is None:
raise Exception("Password must contain atl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_password(password):\n return isinstance(password, str) and len(password) >= 8 and \\\n re.search(r'[A-Z]', password) and re.search(r'[0-9]', password)",
"def validate_password(self, password_field):\n if len(password_field.data) < 8:\n raise ValidationError('Y... | [
"0.8766334",
"0.81289023",
"0.81200564",
"0.80847394",
"0.8010414",
"0.7993104",
"0.78297937",
"0.7824315",
"0.78155774",
"0.7803249",
"0.7767423",
"0.77415377",
"0.7721763",
"0.76823556",
"0.7681701",
"0.7652257",
"0.76191694",
"0.7600995",
"0.75715125",
"0.7533356",
"0.7520... | 0.84100276 | 1 |
Make sure that bzr is available when running in CI. | def test_ensure_bzr_available():
assert is_bzr_installed() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_deploy():\n from fabdeploy.django import test as django_test\n django_test()\n git.add_commit_pull()\n git.push()",
"def _get_bzr_version():\n try:\n value, output, _ = run_shell_command('bzr --version',\n shell=True,\n ... | [
"0.6085656",
"0.5957647",
"0.57713366",
"0.57140285",
"0.56965965",
"0.564991",
"0.5644301",
"0.55707353",
"0.5557706",
"0.5546851",
"0.55418056",
"0.5531211",
"0.5515171",
"0.5443203",
"0.54164296",
"0.53966993",
"0.5394848",
"0.5389168",
"0.5381132",
"0.5380146",
"0.5363527... | 0.7557124 | 0 |
Removes the api version from the href. | def remove_trailing_version_from_href(href):
parsed_url = urlparse.urlsplit(href)
url_parts = parsed_url.path.rsplit('/', 1)
# NOTE: this should match vX.X or vX
expression = re.compile(r'^v([0-9]+|[0-9]+\.[0-9]+)(/.*|$)')
if not expression.match(url_parts.pop()):
LOG.debug('href %s does no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_link():",
"def _strip_version(endpoint):\n if endpoint.endswith('/'):\n endpoint = endpoint[:-1]\n url_bits = endpoint.split('/')\n if re.match(r'v\\d+\\.?\\d*', url_bits[-1]):\n endpoint = '/'.join(url_bits[:-1])\n return endpoint",
"def remove_study_version_dbgap_link(app... | [
"0.6193792",
"0.60921365",
"0.6078247",
"0.5901628",
"0.58109987",
"0.5665509",
"0.5512722",
"0.5504835",
"0.54142016",
"0.54117763",
"0.54097027",
"0.529149",
"0.5282961",
"0.5278921",
"0.5244824",
"0.5241325",
"0.5213375",
"0.52127796",
"0.5143578",
"0.51431906",
"0.5127807... | 0.6932704 | 0 |
Convenience method for joining parts of a URL Any leading and trailing '/' characters are removed, and the parts joined together with '/' as a separator. If last element of 'parts' is an empty string, the returned URL will have a trailing slash. | def url_join(*parts):
parts = parts or [""]
clean_parts = [part.strip("/") for part in parts if part]
if not parts[-1]:
# Empty last element should add a trailing slash
clean_parts.append("")
return "/".join(clean_parts) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _url_join(self, *parts):\n return \"/\".join(map(lambda fragment: fragment.rstrip('/'), parts))",
"def urljoin(*parts):\n def _gen(parts):\n prev = None\n for part in parts:\n if not part:\n continue\n if not prev:\n prev = part\n ... | [
"0.84102356",
"0.82989657",
"0.81839633",
"0.8064334",
"0.79943556",
"0.7882533",
"0.786418",
"0.7630931",
"0.7371415",
"0.6973159",
"0.6902921",
"0.68932605",
"0.68614244",
"0.68232083",
"0.68219864",
"0.67865187",
"0.6781647",
"0.677915",
"0.6769976",
"0.66617376",
"0.66453... | 0.8668859 | 0 |
Get project id from request url if present or empty string otherwise | def _get_project_id(self, request):
project_id = request.environ["masakari.context"].project_id
if project_id in request.url:
return project_id
return '' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_project_id():\n return os.environ.get('project')",
"def __get_project_id(self):\n request = urllib2.Request(self.host_api+\"projects?owner=\"+urllib2.quote(self.owner)+\"&display_name=\"+urllib2.quote(self.project_name))\n # request = urllib2.Request(self.host_api+\"projects?owner=\"+sel... | [
"0.7154755",
"0.70934504",
"0.6984654",
"0.6971364",
"0.6971364",
"0.6971364",
"0.6971364",
"0.6971364",
"0.6708459",
"0.66086614",
"0.6594982",
"0.6558914",
"0.6558914",
"0.6518638",
"0.64804995",
"0.64804995",
"0.64804995",
"0.64804995",
"0.6430157",
"0.63776463",
"0.635488... | 0.8752246 | 0 |
Return href string with proper limit and marker params. | def _get_next_link(self, request, identifier, collection_name):
params = request.params.copy()
params["marker"] = identifier
prefix = self._update_masakari_link_prefix(request.application_url)
url = url_join(prefix,
self._get_project_id(request),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _insert_links(self, limit, offset):\n if limit is None:\n limit = 0\n if offset is None:\n offset = 0\n\n import ckan.plugins.toolkit as toolkit\n import urllib\n import urllib2\n import urlparse\n '''Adds link to the next/prev part (same l... | [
"0.6050559",
"0.58291566",
"0.58065987",
"0.5738649",
"0.57187855",
"0.5685541",
"0.5682918",
"0.56696624",
"0.5668175",
"0.56174916",
"0.5611827",
"0.556549",
"0.55634326",
"0.55570424",
"0.5539954",
"0.5521814",
"0.55146676",
"0.54406375",
"0.5396114",
"0.5370539",
"0.53625... | 0.6111639 | 0 |
Extract integer param from request or fail. | def _get_int_param(request, param):
try:
int_param = utils.validate_integer(request.GET[param], param,
min_value=0)
except exception.InvalidInput as e:
raise webob.exc.HTTPBadRequest(explanation=e.format_message())
return int_param | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_positive_int_param(request, query_params, param_name):\n param = query_params.get(param_name)\n if not param:\n return None\n try:\n param = int(param)\n if param <= 0:\n raise ValueError()\n return param\n except ValueError:\n request.respond('query parameter \"%s\" must be inte... | [
"0.737176",
"0.6762896",
"0.65760314",
"0.654616",
"0.64901876",
"0.64549387",
"0.64112216",
"0.6378887",
"0.62955576",
"0.6280391",
"0.6223324",
"0.6150399",
"0.61250275",
"0.6049242",
"0.60073894",
"0.60064703",
"0.597818",
"0.5947589",
"0.594178",
"0.5940132",
"0.5923045",... | 0.7985158 | 0 |
Retrieves sort keys/directions parameters. Processes the parameters to create a list of sort keys and sort directions that correspond to the 'sort_key' and 'sort_dir' parameter values. These sorting parameters can be specified multiple times in order to generate the list of sort keys and directions. The input parameter... | def get_sort_params(input_params, default_key='created_at',
default_dir='desc'):
params = input_params.copy()
sort_keys = []
sort_dirs = []
while 'sort_key' in params:
sort_keys.append(params.pop('sort_key').strip())
while 'sort_dir' in params:
sort_dirs.append(p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_sort_params(sort_keys, sort_dirs, default_keys=None,\n default_dir='asc'):\n if default_keys is None:\n default_keys = ['created_at']\n\n # Determine direction to use for when adding default keys\n if sort_dirs and len(sort_dirs):\n default_dir_value = sort... | [
"0.72372377",
"0.61290574",
"0.58718145",
"0.5770037",
"0.5766348",
"0.5757473",
"0.57474947",
"0.5730805",
"0.5716173",
"0.566162",
"0.566162",
"0.55787706",
"0.55084854",
"0.54334277",
"0.5427028",
"0.5402491",
"0.53888994",
"0.5301868",
"0.5285601",
"0.52648246",
"0.524790... | 0.75024617 | 0 |
Calculates angular separation in degrees between two objects. ra1, dec1, ra2, dec2 are the coordinates of the two targets in decimal | def ang_sep(ra1,ra2,dec1,dec2):
#print('target_coords: ',ra1,dec1,ra2,dec2)
dra = abs(ra1-ra2)
if dra > 180:
dra = 360 - dra
#convert relevant angles to radians
dec1_rad = np.radians(dec1)
dec2_rad = np.radians(dec2)
ra1_rad = np.radians(ra1)
ra2_rad = np.radians(ra2)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def angular_separation(r1: np.ndarray, r2: np.ndarray) -> float:\n # First compute the rotation that maps r1 to r2.\n dr = r2 @ r1.transpose()\n # Then extract the angle.\n _, angle = transforms3d.axangles.mat2axangle(dr)\n # Normalise the angle.\n if angle > np.pi:\n angle = 2 * np.pi - a... | [
"0.75287974",
"0.7102566",
"0.7089916",
"0.70077497",
"0.64021134",
"0.6401823",
"0.63344175",
"0.6267705",
"0.62399036",
"0.6158805",
"0.5949738",
"0.5878258",
"0.5862246",
"0.5824026",
"0.5824026",
"0.5782027",
"0.5755602",
"0.5734374",
"0.5721164",
"0.56958395",
"0.5695083... | 0.7627773 | 0 |
>>> data = ' CHANG CHUB SEM CHOG RIN PO CHE' >>> normalizeVerseBreak(data) 'CHANG CHUB SEM CHOG RIN PO CHE' >>> data = 'CHANG CHUB SEM CHOG RIN PO CHE /' >>> normalizeVerseBreak(data) 'CHANG CHUB SEM CHOG RIN PO CHE / ' >>> data = 'CHANG CHUB SEM CHOG RIN PO CHE/' >>> normalizeVerseBreak(data) 'CHANG CHUB SEM CHOG RIN ... | def normalizeVerseBreak(string):
string = string.strip()
string = re.sub('\s+/\s?', '/', string)
string = string.replace('/', ' / ')
return string | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_data(data):\n return ' '.join(data.upper().split())",
"def whitespace_sorter(sentence):\r\n sentence_copy = str(sentence)\r\n sentence_copy = sentence_copy.strip() #Remove leading and trailing whitespace (/s)\r\n sentence_copy = re.sub(\" +\", \" \", sentence_copy) #Coerces all multiple... | [
"0.5627176",
"0.5514943",
"0.5392916",
"0.5288041",
"0.5284384",
"0.52544844",
"0.5122039",
"0.5120344",
"0.5118473",
"0.5098055",
"0.50781465",
"0.5062507",
"0.50251794",
"0.5006783",
"0.49919733",
"0.49425045",
"0.4937896",
"0.49310207",
"0.49207133",
"0.48972574",
"0.48935... | 0.7600039 | 0 |
object of type 'New_Style_Boundary' containing all the funcionality that specifically depends on the choice of the boundary condition' | def boundary_lib(self) -> New_Style_Boundary:
return self._boundary_lib | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def boundary(self): # -> BaseGeometry:\n ...",
"def boundary_conditions(self):\n pass",
"def boundary_conditions(particle_outer_radius, boundary_temp):\n\n boundary_condition = [particle_outer_radius, boundary_temp]\n\n return boundary_condition",
"def apply_boundary_conditions(self):\n ... | [
"0.65627015",
"0.6453875",
"0.62970746",
"0.6121181",
"0.60591966",
"0.60413367",
"0.5958082",
"0.5926671",
"0.59197557",
"0.5884173",
"0.58623636",
"0.581189",
"0.58097094",
"0.5777472",
"0.57357526",
"0.5722252",
"0.5700501",
"0.5657504",
"0.56291044",
"0.5623114",
"0.56054... | 0.6487195 | 1 |
the number of energy states the 'particle in a box'state is projected onto | def num_energy_states(self) -> int:
return self._num_energy_states | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __len__(self):\n return self.nparticles",
"def n_pos(self):\n running_total = 0\n for i in range(self.prob.num):\n if self.alphas[i] > 1e-5 > self.prob.C - self.deltas[i] and self.prob.Y[i] == 1:\n running_total += 1\n return running_total if running_tota... | [
"0.6625179",
"0.6520586",
"0.6520586",
"0.64324784",
"0.6431588",
"0.6414873",
"0.63809717",
"0.63734233",
"0.6323586",
"0.6288493",
"0.62755984",
"0.62718546",
"0.6233775",
"0.6207782",
"0.6170476",
"0.6145455",
"0.6141519",
"0.61399394",
"0.6132359",
"0.61210644",
"0.610804... | 0.6643349 | 0 |
see documentation of 'l_to_kl_mapper' | def l_kl_map(self) -> l_to_kl_mapper:
return self._l_kl_map | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def KL2kL(NL, KL, BL):\n # cycle through BL, finding matching inds in NL and thus KL\n # for row in BL, get KL value in row BL[i,0] and col where(NL[BL[i,0],:]==BL[i,1])[0]\n if (BL < 0).any():\n aBL = np.abs(BL)\n kL = np.array([KL[aBL[i, 0], np.where(NL[aBL[i, 0], :] == aBL[i, 1])[0]][0] f... | [
"0.56921595",
"0.5569048",
"0.5549203",
"0.54740924",
"0.54145914",
"0.5406118",
"0.53970444",
"0.53854877",
"0.53566736",
"0.5277632",
"0.52508193",
"0.52366",
"0.5219296",
"0.5178262",
"0.5145818",
"0.51157826",
"0.5106366",
"0.5102655",
"0.5078339",
"0.5077449",
"0.5038405... | 0.8680803 | 0 |
Find a list of (k1, k2) where k1 < k2 with the maximum values of st_prob[k1] ed_prob[k2] | def find_max_triples(st_prob, ed_prob, top_n=5, prob_thd=None, tensor_type="torch"):
if tensor_type == "torch":
st_prob, ed_prob = st_prob.data.numpy(), ed_prob.data.numpy()
product = np.einsum("bm,bn->bmn", st_prob, ed_prob)
# (N, L, L) the lower part becomes zeros, start_idx < ed_idx
upper_pro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_greatest_probability(self):\n greatest = -1\n for i in range(self.dim):\n for j in range(self.dim):\n if self.kb[i][j] > greatest:\n greatest = self.kb[i][j]\n\n return greatest",
"def find_max_triples(p1, p2, topN=5, prob_thd=None):\n ... | [
"0.6394993",
"0.6110282",
"0.6072714",
"0.60599595",
"0.6017126",
"0.6015208",
"0.5910312",
"0.58973885",
"0.58359766",
"0.582623",
"0.58196145",
"0.5813802",
"0.5803053",
"0.58028036",
"0.57886326",
"0.57541484",
"0.5689953",
"0.56894594",
"0.5671669",
"0.5668233",
"0.566437... | 0.64712745 | 0 |
Get topN indices and values of a 2d array, return a tuple of indices and their values, ranked by the value | def top_n_array_2d(array_2d, top_n):
row_indices, column_indices = np.unravel_index(np.argsort(array_2d, axis=None), array_2d.shape)
row_indices = row_indices[::-1][:top_n]
column_indices = column_indices[::-1][:top_n]
sorted_values = array_2d[row_indices, column_indices]
return np.stack([row_indice... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def topN_array_2d(array_2d, topN=None):\n row_indices, column_indices = np.unravel_index(np.argsort(array_2d, axis=None), array_2d.shape)\n row_indices = row_indices[::-1][:topN]\n column_indices = column_indices[::-1][:topN]\n sorted_values = array_2d[row_indices, column_indices]\n sorted_triples =... | [
"0.74073654",
"0.7327787",
"0.71032065",
"0.6694238",
"0.6656095",
"0.6633193",
"0.6503937",
"0.6362402",
"0.63310814",
"0.62197495",
"0.6209443",
"0.6191257",
"0.6189325",
"0.61888635",
"0.6164573",
"0.61391664",
"0.6070247",
"0.60639524",
"0.598961",
"0.5986245",
"0.5982238... | 0.7583843 | 0 |
return signal quality in dbm. wlanSignalQuality is percentage value that represents the signal quality of the network. WLAN_SIGNAL_QUALITY is of type ULONG. This member contains a value between 0 and 100. A value of 0 implies an actual RSSI signal strength of 100 dbm. A value of 100 implies an actual RSSI signal streng... | def getSignalQualityInDBM(self):
return (float(self.wlanSignalQuality) / 2.0) - 100.0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_signal_percent(self):\n # RSSI or this signal value is measured in decibels from 0 (zero) to\n # -120 (minus 120). The closer the value to 0 (zero), the stronger the\n # signal will be.\n if self.rssi < -80:\n return 20\n elif self.rssi < -70:\n retu... | [
"0.6074094",
"0.60217094",
"0.5889179",
"0.57901305",
"0.57396984",
"0.5680173",
"0.56357545",
"0.5527894",
"0.5477314",
"0.54561406",
"0.5389357",
"0.5375582",
"0.5350388",
"0.5338676",
"0.52917403",
"0.5262764",
"0.5253507",
"0.52252936",
"0.52248573",
"0.5217617",
"0.52172... | 0.83052623 | 0 |
return an interface using miniDesc name | def getInterface(self, miniDesc):
for iface in self.ifaces:
if iface.miniDesc() == miniDesc:
return iface
else:
raise Exception('Interface with miniDesc "%s" not found' % miniDesc) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_interface(name=''):\n global interfaces\n return interfaces[name]",
"def _get_interface_name(self):\n return self.__interface_name",
"def _extract_interface(interface_name):\n return re.match(r'e(th?)?((?P<fex>\\d+)/)?(?P<mod>\\d+)/(?P<int>\\d+)', interface_name).groupdict()",
"def interf... | [
"0.681402",
"0.66090214",
"0.6328007",
"0.6283059",
"0.6162838",
"0.6135661",
"0.6117199",
"0.5963388",
"0.5935286",
"0.5923882",
"0.5910261",
"0.5909605",
"0.5899179",
"0.58971596",
"0.5891223",
"0.58635175",
"0.58635175",
"0.58635175",
"0.58635175",
"0.58635175",
"0.5863517... | 0.78897786 | 0 |
return network with profile name | def getProfile(self, profile):
for network in self.networks:
if network.getProfileName() == profile:
return network
else:
raise Exception('Network with profile name "%s" not found' % profile) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_network_profile(arn=None):\n pass",
"def network_profile(self) -> Optional[pulumi.Input['NetworkProfileArgs']]:\n return pulumi.get(self, \"network_profile\")",
"def network_profile(self) -> Optional[pulumi.Input['NetworkProfileArgs']]:\n return pulumi.get(self, \"network_profile\")",
... | [
"0.8034974",
"0.7666455",
"0.7666455",
"0.7470822",
"0.7312471",
"0.7185045",
"0.678201",
"0.6757629",
"0.6633127",
"0.65804386",
"0.65450716",
"0.6517732",
"0.64937603",
"0.64295596",
"0.6365375",
"0.6311133",
"0.6305287",
"0.62889874",
"0.628199",
"0.6279119",
"0.6276328",
... | 0.82880425 | 0 |
return network using ssid | def getSSID(self, ssid):
for network in self.networks:
if network.getSSID() == ssid:
return network
else:
raise Exception('Network with SSID "%s" not found' % profile) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getnetwork(ipaddr):\n return '192.168.1.0/24'",
"def get_network(self):\n return self.get_ip_network()[-1]",
"def joinwifi():\n station = network.WLAN(network.STA_IF) # initiate a station mode\n\n if not station.isconnected():\n print('connecting to network:', ssid())\n ... | [
"0.7319217",
"0.66508794",
"0.651576",
"0.6394354",
"0.6324551",
"0.6259074",
"0.6236336",
"0.6175038",
"0.6138658",
"0.61321485",
"0.60615045",
"0.6059806",
"0.6049224",
"0.6032489",
"0.60294557",
"0.60238683",
"0.5988079",
"0.5976195",
"0.59709895",
"0.5966414",
"0.59601575... | 0.75938874 | 0 |
open handle to Wlan | def openHandle(self):
NegotiatedVersion = DWORD()
self._handle = HANDLE()
log.debug('WlanOpenHandle()')
ret = WlanOpenHandle(1, None, byref(NegotiatedVersion), byref(self._handle))
if ret != ERROR_SUCCESS:
raise WinError(ret)
if self._useCallback:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open(self, handle):\n raise NotImplementedError",
"def open(self) -> None:",
"def open(self) -> None:",
"def open(self) -> None:",
"def open(self):\n pn_link_open(self._impl)",
"def openSensel():\n handle = None\n (error, device_list) = sensel.getDeviceList()\n if device_list.n... | [
"0.63797355",
"0.6268434",
"0.6268434",
"0.6268434",
"0.62281483",
"0.62180805",
"0.60923684",
"0.6082648",
"0.6039862",
"0.6021626",
"0.6021626",
"0.59682363",
"0.59587044",
"0.5914516",
"0.5914516",
"0.5914516",
"0.5914516",
"0.5914516",
"0.5914516",
"0.5914516",
"0.5894515... | 0.6322617 | 1 |
connect a wlan interface using a profile | def wlanConnect(self, iface, profile):
log.debug('WlanInterface wlanConnect() - iface:%s profile:"%s"' % (iface.miniDesc(), profile))
wcp = WLAN_CONNECTION_PARAMETERS()
wcp.wlanConnectMode = wlan_connection_mode_profile
wcp.strProfile = profile
wcp.pDot11Ssid = None # byref(ssid)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect_session(profile):\n os.system('ssh ' + profile)",
"def connect():\n \n print(\"*****Starting connection*****\")\n \n ssid = id_key.network_id #hidden ssid\n key = id_key.network_key #hidden key\n \n station = network.WLAN(network.STA_IF)\n \n if station.isconnected() == True:\n print(\... | [
"0.68901867",
"0.67133456",
"0.6624861",
"0.66222256",
"0.6520829",
"0.64085853",
"0.638917",
"0.6374321",
"0.6367763",
"0.6331932",
"0.6144454",
"0.6085704",
"0.5949704",
"0.59170735",
"0.5864868",
"0.5848089",
"0.5840637",
"0.5806825",
"0.5786279",
"0.5785304",
"0.5770876",... | 0.78789246 | 0 |
disconnect a wlan interface | def wlanDisconnect(self, iface):
log.debug('WlanInterface wlanDisconnect() - iface:%s' % (iface.miniDesc()))
ret = WlanDisconnect( self._handle,
byref(iface.InterfaceGuid),
None)
if ret != ERROR_SUCCESS:
raise WinError(ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _DisconnectAP(self):\n disconnect_command = 'iw dev {interface} disconnect'.format(\n interface=self.interface)\n # This call may fail if we are not connected to any network.\n self._device.Call(disconnect_command)",
"def disconnect_port(self, iface):\n self.iface_config(iface, adminMo... | [
"0.72159076",
"0.70738363",
"0.67676616",
"0.6624292",
"0.66076785",
"0.66066116",
"0.6585626",
"0.65664726",
"0.6516199",
"0.65145594",
"0.64772666",
"0.6396341",
"0.63787943",
"0.63662654",
"0.6359681",
"0.63501954",
"0.6323497",
"0.6318395",
"0.62968045",
"0.626833",
"0.62... | 0.7975275 | 0 |
return profile XML for a defined profile | def wlanGetProfile(self, iface, profile, saveToFile=None):
log.debug('WlanInterface wlanGetProfile() - profile:"%s" saveToFile:%s' % (profile,saveToFile))
sProfile = c_wchar_p(profile)
sProfileXML = c_wchar_p() # create_unicode_buffer(1024)
flags = DWORD(0)
grantedAccess = DWOR... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_wlan_profile_xml(ssid, auth_method, encrypt_method, key_type = \"\", key_material = \"\", key_index = \"\", use_onex = False):\n\n # Try to generate a temporary file for storing the XML profile\n fd, path = tempfile.mkstemp(\".xml\")\n\n # Fill the content\n os.write(fd, '<?xml version=\"1.0\... | [
"0.6350907",
"0.63488406",
"0.6266231",
"0.6177022",
"0.61312056",
"0.6096144",
"0.6061613",
"0.605447",
"0.60457754",
"0.6005076",
"0.5981148",
"0.5963808",
"0.59127927",
"0.58966184",
"0.5859962",
"0.5842467",
"0.58242536",
"0.5814976",
"0.57743406",
"0.5754428",
"0.5705603... | 0.6570712 | 0 |
Get a single action label for the current state, ideally whatever the planner would have outputted if just called on `cstate` in isolation. | def single_action_label(self, cstate):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action2label(action):\n if action[0] == 'shift':\n label = action[0]\n elif action[0] == 'reduce':\n label = '-'.join(list(action))\n else:\n raise ValueError(\"Unrecognized parsing action: {}\".format(action))\n return label",
"def state_name(self):\n return self.stat... | [
"0.68593997",
"0.6409792",
"0.63704884",
"0.6344228",
"0.6292176",
"0.616831",
"0.61657256",
"0.6163822",
"0.6136787",
"0.6057938",
"0.605119",
"0.605119",
"0.6047956",
"0.6044922",
"0.6044922",
"0.6044922",
"0.6044414",
"0.60374177",
"0.6018807",
"0.60048354",
"0.60048354",
... | 0.79932404 | 0 |
Wraps a method of this class in a SSiPP timeout, so that planning can't take too long. Maintains a blacklist of states that caused timeouts before, and prevents relevant methods from being called again on those states by simply raising another timeout. | def _blacklist_decorator(inner_func):
@wraps(inner_func)
def wrapper_func(self, cstate, *args, **kwargs):
assert isinstance(cstate, CanonicalState), \
"func %s was expecting a cstate but got '%r'" \
% (inner_func, cstate)
if cstate._ident_tup() in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timeout(time):\n\n def wrapper(f):\n @wraps(f)\n def wrapped_f(self, event, context):\n return f(self, event, context)\n\n wrapped_f.timeout = time\n return wrapped_f\n\n return wrapper",
"def timeout(time_limit):\n\n class TimeoutException(Exception):\n ... | [
"0.62377894",
"0.61471254",
"0.6033199",
"0.5992332",
"0.59493905",
"0.57512546",
"0.5742238",
"0.5699485",
"0.5643137",
"0.5635711",
"0.56170464",
"0.5599529",
"0.5585652",
"0.5580245",
"0.55567193",
"0.5546809",
"0.55230653",
"0.55142486",
"0.55070794",
"0.5488454",
"0.5446... | 0.6632625 | 0 |
Turn a unique action identifier string (i.e SSiPPformatted action string) into an index into the action list for this problem. | def _act_id(self, act_str):
# FIXME: instead of doing this shit I should just fix the things in
# state_reprs.py so that they can take action IDs (numeric ones) OR
# action names OR BoundActions! Have a family of resolve_action_to_*
# methods that let you convert from any one representa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_action_id(self, action_text: str) -> int:\n\n actions_tuple = tuple(action_text.split('+'))\n return self.action_tuples2ids[actions_tuple] # todo unhandled exception when not found",
"def str_to_action(str):\n raise NotImplementedError",
"def get_action_id(self, action_text: str) ... | [
"0.6287347",
"0.62635666",
"0.6073907",
"0.604243",
"0.5834542",
"0.5821824",
"0.5821046",
"0.58161885",
"0.5769511",
"0.57691544",
"0.56986296",
"0.5698094",
"0.5687889",
"0.5677664",
"0.5606154",
"0.55739564",
"0.5573762",
"0.55202705",
"0.5516037",
"0.55082506",
"0.5484332... | 0.66609216 | 0 |
Dynamically call the function according 'oper' | def process_data(self, oper='SCAN'):
func_name = oper.lower()
return getattr(self, func_name)() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _execute(self, op, time):\n raise NotImplementedError",
"def do_run(calc, a=int, b=int):\n of = calc.oper_func\n calc.log.msg(10, 'Calculating', operation=of, a=a, b=b)\n res = getattr(operator, of, calc.not_found)(a, b)\n calc.log.msg(20, 'Returning', result=res)\n ... | [
"0.61901075",
"0.61292493",
"0.61219674",
"0.60508186",
"0.60292137",
"0.594123",
"0.5882175",
"0.5842769",
"0.58308256",
"0.5827575",
"0.58041626",
"0.57888895",
"0.5762354",
"0.5761433",
"0.5750888",
"0.5736811",
"0.5736043",
"0.5727928",
"0.5691805",
"0.56814253",
"0.56723... | 0.64394444 | 0 |
Assemble mac address from the list | def _get_mac_address(self, mac_numbers):
mac = ""
for num in mac_numbers:
num = self._convert_to_hex(num)
mac = ':'.join((mac, num))
mac = mac[1:]
return mac | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mac_address(self):\n mac = [\n self.random.randint(0x00, 0xff),\n self.random.randint(0x00, 0xff),\n self.random.randint(0x00, 0xff),\n self.random.randint(0x00, 0xff),\n self.random.randint(0x00, 0xff),\n self.random.randint(0x00, 0xff)\... | [
"0.7022228",
"0.68802977",
"0.6582795",
"0.6570698",
"0.6570698",
"0.6570698",
"0.6570698",
"0.6556131",
"0.6456271",
"0.6389757",
"0.63864744",
"0.6316981",
"0.6316593",
"0.63095945",
"0.6283913",
"0.62120837",
"0.6191361",
"0.6191361",
"0.61385566",
"0.61184037",
"0.6116887... | 0.740949 | 0 |
Read private key and certificates from files. Return (private key, certificates) chain pair. | def read_chain_pair(private_key, certificates):
with open(private_key, 'rb') as f:
private_key = f.read()
with open(certificates, 'rb') as f:
certificates = f.read()
return (private_key, certificates) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_key_and_cert(key_file, cert_file):\n with open(cert_file, 'rb') as f:\n cert = x509.load_pem_x509_certificate(f.read(), default_backend())\n with open(key_file, 'rb') as f:\n key = serialization.load_pem_private_key(f.read(), None, backend=default_backend())\n\n ... | [
"0.6391459",
"0.62914973",
"0.5971284",
"0.59437066",
"0.58221966",
"0.57909185",
"0.57617474",
"0.5750648",
"0.564614",
"0.5595037",
"0.5582063",
"0.55411404",
"0.54925364",
"0.5485883",
"0.54124856",
"0.5362128",
"0.5354524",
"0.5340389",
"0.5324609",
"0.5308338",
"0.526386... | 0.8233212 | 0 |
Add sock (a zmq socket) to list of sockets we'll listen for events on | def listen(self, sock):
self.sockets.append(sock)
self.poller.register(sock, zmq.POLLIN) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_socket(self, socket):\n self.add_sockets([socket])",
"def add_sockets(self, sockets):\n if self.io_loop is None:\n self.io_loop = IOLoop.current()\n\n for sock in sockets:\n self._sockets[sock.fileno()] = sock\n self.io_loop.add_handler(sock.fileno(),... | [
"0.6908348",
"0.675583",
"0.66643906",
"0.64296603",
"0.60607636",
"0.6004247",
"0.5915704",
"0.58805346",
"0.5824161",
"0.5776066",
"0.56614673",
"0.56568986",
"0.56186587",
"0.560656",
"0.5605178",
"0.5531999",
"0.5525945",
"0.55209213",
"0.55099356",
"0.547657",
"0.5465054... | 0.7839191 | 0 |
Return the best partial ratio match from fuzzywuzzy module. | def top_partial_ratio(group):
scores = []
for c0, c1 in combinations(group, 2):
score = fuzz.partial_ratio(c0.value, c1.value)
field = c0 if len(c0.value) >= len(c1.value) else c1
scores.append(FuzzyRatioScore(score, field))
scores = sorted(scores, reverse=True, key=lambda s: (s.sco... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fuzzy_partial_ratio(thing_1, thing_2):\n return fuzz.partial_ratio(thing_1, thing_2)",
"def fuzzy_ratio(thing_1, thing_2):\n return fuzz.ratio(thing_1, thing_2)",
"def find_best_match(fpl_teams: List[str], team: str) -> Tuple[str, int]:\n best_ratio = 0.0\n best_match = None\n for t in fpl_teams... | [
"0.767117",
"0.706915",
"0.7045623",
"0.69615054",
"0.688134",
"0.68650913",
"0.6457859",
"0.62769884",
"0.6275168",
"0.60757107",
"0.6075642",
"0.60390335",
"0.60216784",
"0.60216784",
"0.5956916",
"0.5956916",
"0.59508455",
"0.59213847",
"0.5902485",
"0.5899878",
"0.5849218... | 0.7887274 | 0 |
Return the best token set ratio match from fuzzywuzzy module. | def top_token_set_ratio(group):
scores = []
for c0, c1 in combinations(group, 2):
score = fuzz.token_set_ratio(c0.value, c1.value)
tokens_0 = len(c0.value.split())
tokens_1 = len(c1.value.split())
if tokens_0 > tokens_1:
field = c0
tokens = tokens_0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fuzzy_token_sort_ratio(thing_1, thing_2):\n return fuzz.token_sort_ratio(thing_1, thing_2)",
"def find_best_match(fpl_teams: List[str], team: str) -> Tuple[str, int]:\n best_ratio = 0.0\n best_match = None\n for t in fpl_teams:\n if fuzz.partial_ratio(t, team) > best_ratio:\n best... | [
"0.7019757",
"0.6915708",
"0.6894662",
"0.6811242",
"0.6709782",
"0.6509443",
"0.62935543",
"0.6287032",
"0.62503135",
"0.6221222",
"0.62034714",
"0.6132662",
"0.6018528",
"0.59871924",
"0.59778166",
"0.59441316",
"0.59365857",
"0.59181213",
"0.58937454",
"0.5874365",
"0.5842... | 0.75352436 | 0 |
Returns the API version based on the release track. | def GetApiVersion(cls):
if cls.ReleaseTrack() == base.ReleaseTrack.ALPHA:
return 'alpha'
elif cls.ReleaseTrack() == base.ReleaseTrack.BETA:
return 'beta'
return 'v1' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_version(self):\n return self.api_version",
"def get_api_version(session: \"Session\") -> str:\n component_versions = get_component_versions(session)\n return str(component_versions.get(CoordConsts.KEY_API_VERSION, \"2.0.0\"))",
"def api_version(self) -> Optional[str]:\n return pulum... | [
"0.7356627",
"0.73361796",
"0.73104286",
"0.73104286",
"0.73104286",
"0.73104286",
"0.73104286",
"0.73104286",
"0.73104286",
"0.73104286",
"0.73104286",
"0.73104286",
"0.73104286",
"0.73104286",
"0.73104286",
"0.73104286",
"0.73104286",
"0.73104286",
"0.73104286",
"0.73104286",... | 0.8126857 | 0 |
Create Backend Services patch request. | def ComposePatchRequest(self, client, backend_service_ref, replacement):
if backend_service_ref.Collection() == 'compute.regionBackendServices':
return (
client.apitools_client.regionBackendServices,
'Patch',
client.messages.ComputeRegionBackendServicesPatchRequest(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def requestfactory_patch(self, path, data=None, content_type=client.MULTIPART_CONTENT, **extra):\r\n\r\n data = data or {}\r\n patch_data = self._encode_data(data, content_type)\r\n\r\n parsed = urlparse.urlparse(path)\r\n request = {\r\n 'CONTENT_LENGTH': len(patch_data),\r\n 'CONTENT_TY... | [
"0.6822116",
"0.6498407",
"0.6371376",
"0.6356031",
"0.6331954",
"0.63101476",
"0.618666",
"0.61838037",
"0.61745155",
"0.61538756",
"0.61318535",
"0.6130529",
"0.61251915",
"0.6110662",
"0.6103166",
"0.6076066",
"0.6054936",
"0.6054936",
"0.6054936",
"0.6049838",
"0.6041006"... | 0.6702764 | 1 |
Reponsible for validating input addresses in stream or batch form. returns a list containing a single Address object for stream input and multiple for batch input. | def validate(self, params, address_input_data):
processed_address_list = []
# check avoids redundancy for combined 'forward geocode and validate'
# option as API does both by default
if self.__is_address_list_processed:
processed_address_list = address_input_data
els... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __process_smarty_request_list(self, request_list, address_input_data ):\n assert(len(address_input_data) == self.__total_addresses_in_request_list)\n\n processed_address_list = []\n address_iterator = iter(address_input_data)\n for unprocessed_request in request_list: \n ... | [
"0.6725842",
"0.6710126",
"0.6240761",
"0.6221789",
"0.62037283",
"0.6125183",
"0.61011887",
"0.61011887",
"0.61011887",
"0.6095425",
"0.6018221",
"0.5996222",
"0.5996222",
"0.59931666",
"0.59471816",
"0.5929042",
"0.5874366",
"0.5863718",
"0.5857947",
"0.5847198",
"0.5830124... | 0.7343851 | 0 |
Reponsible for forward geocoding input addresses in stream or batch form. returns a list containing a single Address object for stream input and multiple for batch input. | def forward_geocode(self, params, address_input_data ):
processed_address_list = []
# check avoids redundancy for combined 'forward geocode and validate'
# option as API does both by default
if self.__is_address_list_processed:
processed_address_list = address_input_data
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addresses(self) -> pulumi.Input[Sequence[pulumi.Input[str]]]:\n return pulumi.get(self, \"addresses\")",
"def validate(self, params, address_input_data):\n processed_address_list = []\n # check avoids redundancy for combined 'forward geocode and validate' \n # option as API does b... | [
"0.6530636",
"0.64462525",
"0.63802785",
"0.6370371",
"0.6355637",
"0.616385",
"0.6150521",
"0.5960874",
"0.5960874",
"0.5960874",
"0.5901883",
"0.5866094",
"0.58648705",
"0.5802863",
"0.5780841",
"0.57634604",
"0.57634604",
"0.5756493",
"0.57322425",
"0.5726187",
"0.56785333... | 0.7548706 | 0 |
Returns a list of requests each containing SmartyAddressService.MAX_ADDRESSES_PER_REQUEST address input strings. Input Address strings are converted smarty street Lookup objects. The request list is a list of batch partitions, smarty street Batch objects, which serves as the overall address batch. | def __prepare_smarty_request_list(self, address_list):
single_request_batch_partition = Batch()
addresses_per_request = 0
request_list = []
for address in address_list:
if addresses_per_request == SmartyAddressService.MAX_ADDRESSES_PER_REQUEST:
request_list.ap... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __process_smarty_request_list(self, request_list, address_input_data ):\n assert(len(address_input_data) == self.__total_addresses_in_request_list)\n\n processed_address_list = []\n address_iterator = iter(address_input_data)\n for unprocessed_request in request_list: \n ... | [
"0.5991902",
"0.50746",
"0.50179887",
"0.5004752",
"0.4969774",
"0.4932725",
"0.48918006",
"0.4872808",
"0.48422703",
"0.48400947",
"0.48248988",
"0.47963837",
"0.4769254",
"0.47649458",
"0.47551847",
"0.47398427",
"0.4738118",
"0.4730094",
"0.47092748",
"0.46977097",
"0.4692... | 0.7343559 | 0 |
Process request list through smarty streets API and assign response to corresponding address objects. Each individual request contains SmartyAddressService.MAX_ADDRESSES_PER_REQUEST address Lookups, which are assigned candidate addresses by their api. This function chooses the top candidate is chosen and assigns desire... | def __process_smarty_request_list(self, request_list, address_input_data ):
assert(len(address_input_data) == self.__total_addresses_in_request_list)
processed_address_list = []
address_iterator = iter(address_input_data)
for unprocessed_request in request_list:
params = {}... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __prepare_smarty_request_list(self, address_list):\n single_request_batch_partition = Batch()\n addresses_per_request = 0\n request_list = []\n for address in address_list:\n if addresses_per_request == SmartyAddressService.MAX_ADDRESSES_PER_REQUEST:\n requ... | [
"0.67963153",
"0.56317437",
"0.5481398",
"0.54446745",
"0.5351575",
"0.5254347",
"0.51797926",
"0.50109726",
"0.4875006",
"0.48727018",
"0.4871034",
"0.4861196",
"0.4853113",
"0.48028946",
"0.4739545",
"0.47258613",
"0.4718744",
"0.470152",
"0.46981382",
"0.46929234",
"0.4670... | 0.6969019 | 0 |
Displays an options menu with the given options by executing dmenu with the provided list of arguments. Returns the chosen option or None if none of the given options was chosen. | def dmenu(options, args=[], path=DEFAULT_DMENU_PATH):
dmenu = subprocess.Popen([path] + args,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
option_lines = '\n'.join(map(str, options))
option = dmenu.communicate(option_lines.encode('utf-8'))[0] \
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self, args=[], path=DEFAULT_DMENU_PATH):\n options = self.create_options()\n option = dmenu(options, args=args, path=path)\n if option:\n self.handle_option(option, options)",
"def menuItem(*args):\n\toptionsWindow()",
"def show(self):\n # Display the menu.\n ... | [
"0.69564426",
"0.65855235",
"0.6582707",
"0.64486706",
"0.64389974",
"0.6281806",
"0.6219096",
"0.60309243",
"0.6030296",
"0.5987751",
"0.5915396",
"0.5903842",
"0.5899842",
"0.5889831",
"0.58847314",
"0.58633196",
"0.5862723",
"0.58552134",
"0.5834016",
"0.57824904",
"0.5700... | 0.79341877 | 0 |
Handles the option chosen in the dmenu. To be overwritten by subclasses. | def handle_option(self, option, options):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMenuOption():\n return menu_option",
"def handle_select(self):\n #self.selected = input('>> ')\n self.selected = '0'\n if self.selected in ['Q', 'q']:\n sys.exit(1)\n elif self.selected in ['B', 'b']:\n self.back_to_menu = True\n return True\... | [
"0.673435",
"0.66599476",
"0.66203",
"0.65081906",
"0.6503948",
"0.6503179",
"0.64747703",
"0.64747703",
"0.6417105",
"0.6362919",
"0.63450885",
"0.631465",
"0.6263112",
"0.6202966",
"0.6188523",
"0.61634606",
"0.61166906",
"0.60992646",
"0.6090097",
"0.60768914",
"0.6067128"... | 0.6845839 | 0 |
Creates the options with the create_options function and passes them to dmenu with the additional arguments. If an option was selected it is passed to the handle_option function. | def run(self, args=[], path=DEFAULT_DMENU_PATH):
options = self.create_options()
option = dmenu(options, args=args, path=path)
if option:
self.handle_option(option, options) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def menuItem(*args):\n\toptionsWindow()",
"def optionMenu(*args, alwaysCallChangeCommand: bool=True, annotation: Union[AnyStr, bool]=\"\",\n backgroundColor: Union[List[float, float, float], bool]=None, beforeShowPopup:\n Script=None, changeCommand: Script=None, defineTemplate: AnyStr... | [
"0.65391994",
"0.64011323",
"0.6330111",
"0.6309242",
"0.62822783",
"0.6005424",
"0.60025024",
"0.5913053",
"0.5886426",
"0.58417106",
"0.57628626",
"0.57540554",
"0.5687309",
"0.56249946",
"0.5620401",
"0.5612325",
"0.5583547",
"0.55540794",
"0.5524454",
"0.5461041",
"0.5457... | 0.68001723 | 0 |
Test for Transform2NormInd.run() for test ``eopy.matchup.matchupIO.MatchUp`` object with data for multiple matchup series random uncertainty type only | def test_run_multi_r__(self):
# Test Description
# ================
#
# 1. This test intialises an example *eopy.matchup.matchupIO.MatchUp* object
#
# 2. Compare transformed dataset to expected value
##############################################################... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def return_MatchUpTest_r__():\n\n ####################################################################################################################\n # 1. Initialise test data\n ####################################################################################################################\n\n v... | [
"0.618169",
"0.61430645",
"0.59169275",
"0.57321066",
"0.57125336",
"0.5702606",
"0.5576436",
"0.55339223",
"0.5435399",
"0.54145247",
"0.53927404",
"0.53498745",
"0.534863",
"0.5331139",
"0.5256002",
"0.5251248",
"0.5210866",
"0.5170504",
"0.5157448",
"0.51404893",
"0.511381... | 0.68906015 | 0 |
A simple NonRepairableRBD with three intermediate nodes in parallel. | def rbd_parallel() -> NonRepairableRBD:
edges = [(1, 2), (1, 3), (1, 4), (2, 5), (3, 5), (4, 5)]
reliabilities = {
2: FixedEventProbability.from_params(1 - 0.8),
3: FixedEventProbability.from_params(1 - 0.9),
4: FixedEventProbability.from_params(1 - 0.85),
}
return NonRepairableR... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rbd_repeated_component_parallel() -> NonRepairableRBD:\n edges = [(1, 2), (1, 3), (1, 4), (1, 5), (2, 6), (3, 6), (4, 6), (5, 6)]\n reliabilities = {\n 2: FixedEventProbability.from_params(1 - 0.8),\n 3: FixedEventProbability.from_params(1 - 0.9),\n 4: FixedEventProbability.from_para... | [
"0.6714331",
"0.6077196",
"0.5871187",
"0.5761095",
"0.575306",
"0.57487047",
"0.5707745",
"0.5683427",
"0.56822884",
"0.5626346",
"0.5609467",
"0.5545553",
"0.553127",
"0.55290705",
"0.55273926",
"0.55230594",
"0.5517176",
"0.55019444",
"0.547357",
"0.5447232",
"0.54407746",... | 0.7042741 | 0 |
Basically rbd_parallel with a repeated component (component 2). | def rbd_repeated_component_parallel() -> NonRepairableRBD:
edges = [(1, 2), (1, 3), (1, 4), (1, 5), (2, 6), (3, 6), (4, 6), (5, 6)]
reliabilities = {
2: FixedEventProbability.from_params(1 - 0.8),
3: FixedEventProbability.from_params(1 - 0.9),
4: FixedEventProbability.from_params(1 - 0.8... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rbd_parallel() -> NonRepairableRBD:\n edges = [(1, 2), (1, 3), (1, 4), (2, 5), (3, 5), (4, 5)]\n reliabilities = {\n 2: FixedEventProbability.from_params(1 - 0.8),\n 3: FixedEventProbability.from_params(1 - 0.9),\n 4: FixedEventProbability.from_params(1 - 0.85),\n }\n return No... | [
"0.66087776",
"0.59290457",
"0.5882417",
"0.5852172",
"0.5571424",
"0.5562024",
"0.55331624",
"0.544469",
"0.537368",
"0.5371877",
"0.5354507",
"0.5273932",
"0.5170079",
"0.51246303",
"0.50607854",
"0.5056613",
"0.50508237",
"0.50475144",
"0.50254637",
"0.5022691",
"0.4972075... | 0.7394611 | 0 |
rbd2 but k of node 7 is =2. | def rbd2_koon() -> NonRepairableRBD:
edges = [(1, 2), (2, 3), (2, 4), (4, 7), (3, 5), (5, 6), (6, 7), (7, 8)]
reliabilities = {
2: surv.Weibull.from_params([20, 2]),
3: surv.Weibull.from_params([100, 3]),
4: surv.Weibull.from_params([50, 20]),
5: surv.Weibull.from_params([15, 1.2... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rbd3_koon2() -> NonRepairableRBD:\n edges, reliabilities = rbd3_nodes_edges_components()\n k = {2: 2}\n return NonRepairableRBD(edges, reliabilities, k)",
"def rbd3_koon1() -> NonRepairableRBD:\n edges, reliabilities = rbd3_nodes_edges_components()\n k = {5: 2}\n return NonRepairableRBD(edg... | [
"0.64837515",
"0.6033989",
"0.58228284",
"0.56298786",
"0.5610498",
"0.5605671",
"0.55991936",
"0.55821586",
"0.5548604",
"0.55299145",
"0.5437083",
"0.54195094",
"0.53975606",
"0.5387104",
"0.53656757",
"0.5359423",
"0.5346822",
"0.53252655",
"0.53040564",
"0.5302914",
"0.52... | 0.6389324 | 1 |
Compute the intersection area of a numpy array of boxes and a single box. | def intersection(boxes, box):
ix = np.maximum(0, np.minimum(box[2], boxes[:,2]) - np.maximum(box[0], boxes[:,0]))
iy = np.maximum(0, np.minimum(box[3], boxes[:,3]) - np.maximum(box[1], boxes[:,1]))
return ix*iy | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_inters(box, boxes, box_area):\n # Calculate intersection areas\n y1 = np.maximum(box[0], boxes[:, 0])\n y2 = np.minimum(box[2], boxes[:, 2])\n x1 = np.maximum(box[1], boxes[:, 1])\n x2 = np.minimum(box[3], boxes[:, 3])\n return np.divide(np.maximum(x2 - x1, 0) * np.maximum(y2 - y1, 0)... | [
"0.7640445",
"0.73185265",
"0.7236327",
"0.7168402",
"0.7168402",
"0.7132642",
"0.7098993",
"0.70911914",
"0.7082353",
"0.70558786",
"0.696013",
"0.6940942",
"0.6880113",
"0.68699026",
"0.6814332",
"0.68049055",
"0.6767781",
"0.66969436",
"0.66479206",
"0.66479206",
"0.664419... | 0.78136355 | 0 |
ensures that the correct number of keys and values are emitted | def test_has_correct_number_of_keys_and_values(self):
self.has_correct_number_of_keys_and_values(2, 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_reduce(key, values):\n yield \"%s: %d\\n\" % (key, len(values))",
"def iter_values_len(self):\n for key, values in self.data.items():\n yield key, len(values)",
"def reduce_length(key, values):\n yield str((key, len(values)))",
"def reducer(key, vals):\n count = 0\n for p i... | [
"0.5706788",
"0.57027614",
"0.55487025",
"0.54131407",
"0.539261",
"0.53575903",
"0.5339979",
"0.5187678",
"0.5187663",
"0.5140506",
"0.5138147",
"0.5101639",
"0.5050154",
"0.50461453",
"0.50327146",
"0.50267106",
"0.50193614",
"0.4986483",
"0.49846265",
"0.49811524",
"0.4981... | 0.60382676 | 0 |
ensures that a line is emitted for each word in each file | def test_emits_line_for_each_word_in_each_file(self):
with open(self.default_fixture) as f:
output = self.run_mapper()
input = f.readlines()
num_files = len(input)
total_words = 0
for line in input:
total_words += len(line.strip().split... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_runner(self):\n with open(self.filename) as doc:\n text = doc.readlines()\n for line in text:\n for word in line.split():\n yield word",
"def word_iterator(folder):\n for filename in glob.glob(os.path.join(folder, \"*.txt\")):\n with codecs.op... | [
"0.6799167",
"0.6284839",
"0.61223036",
"0.60836124",
"0.60295254",
"0.5902215",
"0.5849417",
"0.5822456",
"0.57699835",
"0.57522106",
"0.569624",
"0.56763154",
"0.56692684",
"0.5667381",
"0.56594104",
"0.56553334",
"0.5640591",
"0.56372964",
"0.56246144",
"0.5605495",
"0.559... | 0.6906594 | 0 |
ensures that the correct number of keys and values are emitted | def test_has_correct_number_of_keys_and_values(self):
self.has_correct_number_of_keys_and_values(2, 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_reduce(key, values):\n yield \"%s: %d\\n\" % (key, len(values))",
"def iter_values_len(self):\n for key, values in self.data.items():\n yield key, len(values)",
"def reduce_length(key, values):\n yield str((key, len(values)))",
"def reducer(key, vals):\n count = 0\n for p i... | [
"0.5707167",
"0.5701873",
"0.55485255",
"0.5414439",
"0.5392383",
"0.53581417",
"0.5340053",
"0.51869917",
"0.5186937",
"0.51407546",
"0.5138803",
"0.51028943",
"0.5050025",
"0.5047798",
"0.5033274",
"0.5025732",
"0.5018922",
"0.49879548",
"0.49855825",
"0.49825802",
"0.49825... | 0.6038293 | 1 |
tests that each line is accounted for in the sum produced as output | def test_sum_of_output_equals_length_of_input(self):
output_total_sum = 0
for line in self.run_reducer_tokenize():
output_total_sum += int(line[1][0])
with open(self.default_fixture) as f:
input_len = len(f.readlines())
self.assertEqual(output_total_sum, input... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_expected_sum(inputs, expected):\n print(\"\\nRunning test_expected with {} as input and {} as expected output\".format(inputs, expected))\n assert inputs[0] + inputs[1] == expected",
"def test_sum(n, m, o, result):\n from series import sum_series\n assert sum_series(n, m, o) == result",
"d... | [
"0.6509527",
"0.61868066",
"0.61228985",
"0.59584236",
"0.59546816",
"0.5910473",
"0.59024125",
"0.58850664",
"0.5883609",
"0.5875183",
"0.585172",
"0.58443475",
"0.58325183",
"0.5818679",
"0.58184326",
"0.58069396",
"0.5782557",
"0.5773281",
"0.57656586",
"0.5758806",
"0.573... | 0.6357645 | 1 |
This script analyzes possible portfolios based on the calculated parameters on the observed data, and the user inputted investment. | def generate_portfolio(S_0, params):
public_client = gdax.PublicClient()
allvar = []
sumvar = 0
for coin in params:
theta = coin[0]
v = theta[0]
T = coin[1]
prod_id = coin[2]
# Get the current value of the coin, i.e. how much you bought
name = prod_id + '-USD'
stats = public_client.get_product_24hr_st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_trading_start(context, data):\n factors = pipeline_output('ff_example')\n\n # get the data we're going to use\n returns = factors['returns']\n mkt_cap = factors.sort_values(['market_cap'], ascending=True)\n be_me = factors.sort_values(['be_me'], ascending=True)\n\n # to compose the six... | [
"0.6095031",
"0.5822337",
"0.58005035",
"0.5798782",
"0.5752552",
"0.57133955",
"0.5679745",
"0.56412446",
"0.5630844",
"0.5596643",
"0.5596643",
"0.5586385",
"0.55733144",
"0.55497605",
"0.55235076",
"0.54996634",
"0.54918146",
"0.5452439",
"0.54508233",
"0.54480547",
"0.537... | 0.5986981 | 1 |
Convert the character in the [ ] for a task into a TaskStatus | def _get_status_from_char(char: str) -> TaskStatus:
if char == "c":
return TaskStatus.CANCELED
elif char == "b":
return TaskStatus.BLOCKED
elif char == " ":
return TaskStatus.UNSCHEDULED
elif char == "x":
return TaskStatus.DONE
elif char == "?":
return TaskSta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def task_status():\n pass",
"def task_status(self) -> str:\n return self._task_status",
"async def get_task_status(task_id: TaskId):",
"def fuota_task_status(self) -> Optional[str]:\n return pulumi.get(self, \"fuota_task_status\")",
"def _parse_status(self, status):\n if status in (... | [
"0.6113151",
"0.60610837",
"0.5982466",
"0.58361703",
"0.5676092",
"0.562448",
"0.5620659",
"0.5590581",
"0.5534794",
"0.5493304",
"0.5449712",
"0.5449053",
"0.5443019",
"0.54307556",
"0.54105866",
"0.53677195",
"0.5367107",
"0.53506756",
"0.53475046",
"0.5340073",
"0.5264325... | 0.7188169 | 0 |
Slices a panel once at an angle into two new panels | def single_slice_panels(page,
horizontal_vertical=None,
type_choice=None,
skew_side=None,
number_to_slice=0
):
# Remove panels which are too small
relevant_panels = []
if len(page.childre... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _slice_at_axis(sl, axis):\n return (slice(None),) * axis + (sl,) + (...,)",
"def animate_slices_multi(field='uu1', datadir1='data/', datadir2='data/', proc=-1, extension='xz',\n format='native', tmin=0., tmax=1.e38, wait=0.,\n amin=0., amax=1., transform='', oldfile=Fal... | [
"0.57020974",
"0.5570688",
"0.5558747",
"0.545153",
"0.5445056",
"0.543105",
"0.535599",
"0.5348452",
"0.5087993",
"0.50807226",
"0.50238377",
"0.50055045",
"0.5003114",
"0.49961782",
"0.49961782",
"0.49851263",
"0.49696037",
"0.49594927",
"0.49540603",
"0.49380317",
"0.49127... | 0.63570553 | 0 |
This function takes all the first child panels of a page and moves them to form a zigzag or a rhombus pattern | def box_transform_page(page, direction_list=[]):
if len(page.children) > 1:
# For all children of the page
for idx in range(0, len(page.children)-1):
# Take two children at a time
p1 = page.get_child(idx)
p2 = page.get_child(idx+1)
change_proportio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def box_transform_panels(page, type_choice=None, pattern=None):\n\n if type_choice is None:\n type_choice_prob = np.random.random()\n if type_choice_prob < cfg.panel_box_trapezoid_ratio:\n type_choice = \"trapezoid\"\n else:\n type_choice = \"rhombus\"\n\n if type_c... | [
"0.6271615",
"0.54973686",
"0.5387132",
"0.5235147",
"0.52252686",
"0.5174454",
"0.5173184",
"0.5033678",
"0.5033185",
"0.5014299",
"0.5011081",
"0.50006324",
"0.49946687",
"0.49603772",
"0.49424213",
"0.49365565",
"0.49298054",
"0.49220905",
"0.49138784",
"0.48819068",
"0.48... | 0.62816256 | 0 |
Adds panel boundary transformations to the page | def add_transforms(page):
# Transform types
# Allow choosing multiple
transform_choice = ["slice", "box"]
# Slicing panels into multiple panels
# Works best with large panels
if "slice" in transform_choice:
page = single_slice_panels(page)
# Makes v cuts happen more often 1/4 ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_main_panel(self):\n self.panel = wx.Panel(self)\n\n self.init_plot()\n self.canvas = FigCanvas(self.panel, -1, self.fig)\n\n self.control_box = VSControlBox(self.panel, -1, 'Information board')\n\n self.vbox = wx.BoxSizer(wx.VERTICAL)\n self.vbox.Add(self.canvas... | [
"0.5654674",
"0.55271375",
"0.5385923",
"0.5355535",
"0.53435576",
"0.53429335",
"0.5328772",
"0.52715266",
"0.5230099",
"0.52209806",
"0.5134633",
"0.50963074",
"0.50835866",
"0.506619",
"0.5044313",
"0.50324744",
"0.5028184",
"0.5028184",
"0.5023393",
"0.500031",
"0.4988787... | 0.605634 | 0 |
Convert a package (as found by setuptools.find_packages) e.g. "foo.bar" to usable path e.g. "foo/bar" No idea if this works on windows | def package_to_path(package):
return package.replace('.','/') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_package_path():\n package_name = get_package_name()\n return package_name.replace('.', '/')",
"def get_packages_path_from_package(package):\n root = finder.get_package_root(package)\n\n if is_built_package(package):\n package_name_folder = os.path.dirname(root)\n\n return os.pat... | [
"0.7921618",
"0.7368294",
"0.7326123",
"0.70896804",
"0.70801365",
"0.6791065",
"0.6757227",
"0.67504627",
"0.6700731",
"0.66353977",
"0.66276276",
"0.6621615",
"0.6564424",
"0.6564424",
"0.65590894",
"0.6505718",
"0.63585734",
"0.6354153",
"0.62997335",
"0.6271722",
"0.62491... | 0.8622001 | 0 |
Get the subdirectories within a package This will include resources (nonsubmodules) and submodules | def find_subdirectories(package):
try:
subdirectories = next(os.walk(package_to_path(package)))[1]
except StopIteration:
subdirectories = []
return subdirectories | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def walk_package(pkgname, root):\n dirs = []\n files = []\n for name in pkg_resources.resource_listdir(pkgname, str(root)):\n fullname = root / name\n if pkg_resources.resource_isdir(pkgname, str(fullname)):\n dirs.append(fullname)\n else:\n files.append(Path(nam... | [
"0.7408176",
"0.6981932",
"0.6977739",
"0.69128346",
"0.6908319",
"0.6908319",
"0.6908319",
"0.68290293",
"0.67712396",
"0.6679647",
"0.6656998",
"0.6650802",
"0.66113985",
"0.65714127",
"0.65617687",
"0.6516385",
"0.65129155",
"0.65035087",
"0.6490898",
"0.64712936",
"0.6428... | 0.7587221 | 0 |
For a list of packages, find the package_data This function scans the subdirectories of a package and considers all nonsubmodule subdirectories as resources, including them in the package_data Returns a dictionary suitable for setup(package_data=) | def find_package_data(packages):
package_data = {}
for package in packages:
package_data[package] = []
for subdir in find_subdirectories(package):
if '.'.join((package, subdir)) in packages: # skip submodules
logging.debug("skipping submodule %s/%s" % (package, subdir... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_package_data(package):\n walk = [(dirpath.replace(package + os.sep, '', 1), filenames)\n for dirpath, dirnames, filenames in os.walk(package)\n if not os.path.exists(os.path.join(dirpath, '__init__.py'))]\n\n filepaths = []\n for base, filenames in walk:\n filepaths.ex... | [
"0.74882954",
"0.7475205",
"0.7218244",
"0.7056486",
"0.68890065",
"0.68552727",
"0.66472167",
"0.6606134",
"0.6553142",
"0.6551368",
"0.6509173",
"0.62634075",
"0.6203264",
"0.6189386",
"0.61807597",
"0.6176723",
"0.61635065",
"0.6163499",
"0.6126401",
"0.6013186",
"0.601318... | 0.76023054 | 0 |
Generate the save path for an image. If a modifier string is provided, this is added between the existing name and the extension. e.g. fname="moon.jpeg" modstirng="cropped" > "moon_cropped.jpeg". This is then joined with the output directory. If no modiifer, just returns joined path of outdir and fname. | def genSavePath(outdir, fname, modstring=None):
if modstring:
base,ext = os.path.splitext(fname)
fname = f"{base}_{modstring}.{ext}"
writepath = os.path.join(outdir, fname)
return writepath | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output_filename(self, modifier):\n fs = self._filesystem\n output_filename = fs.join(self._root_output_dir, self._test_name)\n return fs.splitext(output_filename)[0] + modifier",
"def name_final_path(out_img_folder):\n if out_img_folder == None:\n return \"./.out_hidden_images\... | [
"0.6506808",
"0.61701065",
"0.5883275",
"0.5868304",
"0.5847001",
"0.5811345",
"0.5766814",
"0.5759355",
"0.57464373",
"0.57153183",
"0.5675875",
"0.5666476",
"0.5665445",
"0.5655566",
"0.56509286",
"0.5640137",
"0.562522",
"0.55997884",
"0.55983824",
"0.5587275",
"0.55767787... | 0.731317 | 0 |
Convert image to a regular baseline JPEG. Quality option is ignored if useexistingqtables=True. | def savebaselineJPEG(image, fname, outpath, optimize=True, quality=75, recompressed=False, useexistingqtables=False, preserve_name=False):
if not preserve_name:
if recompressed:
fpath = genSavePath(outpath, fname, modstring=f"recompressed_q{quality}")
else:
fpath = genSavePa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_to_jpeg(image, quality=90):\n\n\t# Load the image into a new BytesIO\n\tsImg = BytesIO(image)\n\n\t# Create an empty BytesIO for the new image\n\tsNewImg = BytesIO(b'')\n\n\t# Create a new Pillow instance from the raw data\n\toImg = Pillow.open(sImg)\n\n\t# If the mode is not valid\n\tif oImg.mode not ... | [
"0.54743165",
"0.54736084",
"0.5438891",
"0.54282427",
"0.541862",
"0.53912777",
"0.53576815",
"0.52602875",
"0.5242374",
"0.52363783",
"0.52289176",
"0.521572",
"0.5162085",
"0.51128095",
"0.51099354",
"0.5074247",
"0.50239307",
"0.5019632",
"0.5016915",
"0.5016185",
"0.4993... | 0.7245555 | 0 |
Save a rotated version of theimage. | def saverotation(image, fname, outpath, degreescounterlockwise=90, preserve_name=False):
if not preserve_name:
fpath = genSavePath(outpath, fname, modstring=f"rotated_{degreescounterlockwise}")
else:
fpath = genSavePath(outpath, fname)
im = copy(image)
im = im.rotate(degreescounterlockwi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate(image_path):\n try:\n with Image.open(image_path) as img:\n img = ImageOps.exif_transpose(img)\n img.save(image_path, format=img.format, quality=95)\n except Exception as e:\n log.warn(f'Cannot rotate input image: [{e}]')",
"def apply_rotation(image):\n\n\t# L... | [
"0.70346487",
"0.68889385",
"0.682253",
"0.6747778",
"0.6635483",
"0.6627623",
"0.6563121",
"0.6496392",
"0.6405352",
"0.63929117",
"0.63382024",
"0.6252712",
"0.61955154",
"0.61868703",
"0.61305135",
"0.6124323",
"0.61061513",
"0.60409236",
"0.60030663",
"0.5996765",
"0.5981... | 0.7409973 | 0 |
Save a thumbnail of the image, preserves aspect ratio, so longest side will be of size[max(x,y)] | def savethumb(image, fname, outpath, size=(128,128), preserve_name=False):
if not preserve_name:
fpath = genSavePath(outpath, fname, modstring=f"thumbnail_{size[0]}_{size[1]}")
else:
fpath = genSavePath(outpath, fname)
im = copy(image)
im.thumbnail(size)
try:
im.save(fpath, s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_thumbnail(filepath):\n img = Image.open(filepath)\n thumb = None\n w, h = img.size\n\n # if it is exactly 128x128, do nothing\n if w == 128 and h == 128:\n return True\n\n # if the width and height are equal, scale down\n if w == h:\n thumb = img.resize((128, 128), Image... | [
"0.6931515",
"0.68739617",
"0.68509567",
"0.68389434",
"0.6793269",
"0.6591011",
"0.6537345",
"0.6449486",
"0.6414779",
"0.6377539",
"0.6353064",
"0.63198406",
"0.6311073",
"0.6295751",
"0.6291895",
"0.6244799",
"0.6227591",
"0.6221736",
"0.6218256",
"0.62178695",
"0.6205242"... | 0.7045417 | 0 |
Save a cropped version of the image. | def savecrop(image, fname, outpath, cropabsolute=None, cropfactors=[0.2, 0.2, 0.2, 0.2], preserve_name=False):
if cropabsolute:
if type(cropabsolute) != list:
raise Exception("cropabsolute must be a list of length 4.")
else:
if len(cropabsolute) !=4:
raise Exc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Save_Image_Crop(img, x, y, width, height, filename = None, path = 'Predictions'):\n img = img[y:y+height, x:x+width,:]\n\n if filename is not None:\n try: \n os.mkdir(path)\n except OSError as error: \n print('') \n fig, ax = plt.subplots(figsize=(18, 20))\n ... | [
"0.7306745",
"0.69884664",
"0.6980087",
"0.6949157",
"0.687741",
"0.6825131",
"0.6791875",
"0.66822034",
"0.66574806",
"0.66544116",
"0.66482884",
"0.66326034",
"0.65988314",
"0.6507213",
"0.6493506",
"0.6481142",
"0.6444658",
"0.63948953",
"0.6392374",
"0.63720816",
"0.63054... | 0.70799524 | 1 |
Save a watermarked version of the image. resize watermark to 10% of the image height, with a minimum height of 40 | def savewatermarked(image, fname, outpath, watermark, preserve_name=False):
im = image.copy()
if not preserve_name:
fpath = genSavePath(outpath, fname, modstring=f"watermarked")
else:
fpath = genSavePath(outpath, fname)
targetheight = int(image.height / 10)
waterwidthscaler = wa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_watermark(self, image, watermark, position='scale', opacity=1, format=None):",
"def watermark(im, credits, opacity=1):\n # First resize mark to make it appropriate size\n logoURL = 'https://s3.amazonaws.com/static.thecrimson.com' + \\\n '/images/feature/thc-logo-large.png'\n imfile = Stri... | [
"0.7318583",
"0.6755734",
"0.66474384",
"0.6608156",
"0.6311425",
"0.5929534",
"0.5910654",
"0.58472747",
"0.58287114",
"0.58228457",
"0.5805072",
"0.56639534",
"0.5578972",
"0.55572283",
"0.5513554",
"0.5510311",
"0.55005735",
"0.5479865",
"0.5456375",
"0.5421586",
"0.541545... | 0.78452754 | 0 |
Save a version of the file with an added border, controlled by the colour and width parameters. | def saveborder(image, fname, outpath, width=20, colour="black", preserve_name=False):
im = image.copy()
if not preserve_name:
fpath = genSavePath(outpath, fname, modstring=f"border{width}{colour}")
else:
fpath = genSavePath(outpath, fname)
im = ImageOps.expand(im, border=width, fill=col... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_visualization_to_file(self, file_name, length = 90):\n session = self.capture_last(length)\n visualizer.animate(session , 0, length, name = file_name, min_x = -1, max_x = 1, min_y = -1, max_y = 1, show = False )",
"def write(self, file_name, width=1500.0, height=1000.0):\n with ope... | [
"0.5784574",
"0.56733894",
"0.5626295",
"0.5541043",
"0.5428487",
"0.5386171",
"0.5383418",
"0.53502595",
"0.5343739",
"0.5342087",
"0.5294229",
"0.5275449",
"0.52629405",
"0.5256234",
"0.5255994",
"0.52103263",
"0.5183001",
"0.5153634",
"0.51445657",
"0.5137024",
"0.51188093... | 0.72179383 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.