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 |
|---|---|---|---|---|---|---|
Return addition config section for coils. | def get_coil_config_section(cls) -> Optional[str]:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_coil_config_section(cls):\n return None",
"def get_config(self):\n return self.cat_feats_cfg",
"def _getConfigName(self):\n return \"%s_processCoadd_config\" % (self.config.coaddName,)",
"def get_rec_config(self):\n conf_map = {}\n if len(self.reconstructions.text()... | [
"0.6866842",
"0.61183715",
"0.58979475",
"0.58378327",
"0.5800856",
"0.573693",
"0.57158256",
"0.5709645",
"0.5694161",
"0.5682659",
"0.56358176",
"0.5625038",
"0.5527064",
"0.5511581",
"0.550774",
"0.5460539",
"0.5455494",
"0.54532677",
"0.54231423",
"0.5389646",
"0.53817236... | 0.69864786 | 0 |
Validate coil config for platform. | def validate_coil_section(self, driver, config) -> dict:
if self.get_coil_config_section():
spec = self.get_coil_config_section() # pylint: disable-msg=assignment-from-none
config = driver.machine.config_validator.validate_config(spec, config, driver.name)
elif config:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_coil_section(self, driver, config):\n base_spec = [\"device\"]\n if self.__class__.get_coil_config_section():\n base_spec.append(self.__class__.get_coil_config_section())\n driver.machine.config_validator.validate_config(\n \"coils\", config, driver.name,\n ... | [
"0.70886606",
"0.6907376",
"0.6907376",
"0.6905999",
"0.6546647",
"0.64142686",
"0.62825555",
"0.6279739",
"0.62622815",
"0.62202287",
"0.6197608",
"0.6177871",
"0.61492246",
"0.61078686",
"0.608677",
"0.6083871",
"0.6074787",
"0.5983777",
"0.5934141",
"0.58738196",
"0.585251... | 0.7257929 | 0 |
Set pulse on hit rule on driver. Pulses a driver when a switch is hit. When the switch is released the pulse continues. Typically used for autofire coils such as pop bumpers. | def set_pulse_on_hit_rule(self, enable_switch: SwitchSettings, coil: DriverSettings):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pulse_on_hit_rule(self, enable_switch, coil):\n raise NotImplementedError",
"def set_pulse_on_hit_rule(self, enable_switch, coil):\n self.log.info(\"set_pulse_on_hit_rule(coil=%s sw=%s)\" %\n (coil.hw_driver.number, enable_switch.hw_switch.number))\n self.commun... | [
"0.73512125",
"0.72260875",
"0.7224152",
"0.7212513",
"0.71062016",
"0.6979767",
"0.69002014",
"0.6871125",
"0.64783454",
"0.64376444",
"0.63576806",
"0.6283544",
"0.6267186",
"0.6244172",
"0.6027351",
"0.5870278",
"0.5840956",
"0.57337576",
"0.5722434",
"0.5720375",
"0.56807... | 0.7381012 | 0 |
Set pulse on hit and release rule to driver. Pulses a driver when a switch is hit. When the switch is released the pulse is canceled. Typically used on the main coil for dual coil flippers without eos switch. | def set_pulse_on_hit_and_release_rule(self, enable_switch: SwitchSettings, coil: DriverSettings):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pulse_on_hit_and_release_rule(self, enable_switch, coil):\n raise NotImplementedError",
"def set_pulse_on_hit_and_release_rule(self, enable_switch, coil):\n self.log.info(\"set_pulse_on_hit_and_release_rule(coil=%s sw=%s)\" %\n (coil.hw_driver.number, enable_switch.hw_... | [
"0.7406781",
"0.7117068",
"0.71164155",
"0.69559455",
"0.6920032",
"0.6804113",
"0.6787851",
"0.67864007",
"0.6751273",
"0.66386086",
"0.66331583",
"0.64953303",
"0.59653443",
"0.5928787",
"0.59168535",
"0.5900597",
"0.5824056",
"0.5651535",
"0.5548163",
"0.5493299",
"0.53989... | 0.7318522 | 1 |
Set pulse on hit and enable and release rule on driver. Pulses a driver when a switch is hit. Then enables the driver (may be with pwm). When the switch is released the pulse is canceled and the driver gets disabled. Typically used for single coil flippers. | def set_pulse_on_hit_and_enable_and_release_rule(self, enable_switch: SwitchSettings, coil: DriverSettings):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pulse_on_hit_and_release_rule(self, enable_switch: SwitchSettings, coil: DriverSettings):\n raise NotImplementedError",
"def set_pulse_on_hit_and_enable_and_release_rule(self, enable_switch, coil):\n raise NotImplementedError",
"def set_pulse_on_hit_and_release_rule(self, enable_switch, c... | [
"0.72877467",
"0.7178663",
"0.71179587",
"0.7099288",
"0.6991583",
"0.6966409",
"0.6957039",
"0.6921401",
"0.6898555",
"0.6874787",
"0.676784",
"0.675397",
"0.6602575",
"0.63033146",
"0.6220044",
"0.6219758",
"0.61118585",
"0.60108113",
"0.59594446",
"0.59371346",
"0.582267",... | 0.7253777 | 1 |
Set pulse on hit and enable and release and disable rule on driver. Pulses a driver when a switch is hit. When the switch is released the pulse is canceled and the driver gets disabled. When the eos_switch is hit the pulse is canceled and the driver becomes disabled. Typically used on the main coil for dualwound coil f... | def set_pulse_on_hit_and_release_and_disable_rule(self, enable_switch: SwitchSettings,
eos_switch: SwitchSettings, coil: DriverSettings,
repulse_settings: Optional[RepulseSettings]):
raise NotImplementedE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pulse_on_hit_and_enable_and_release_and_disable_rule(self, enable_switch: SwitchSettings,\n eos_switch: SwitchSettings, coil: DriverSettings,\n repulse_settings: Optional[RepulseS... | [
"0.75663674",
"0.7497523",
"0.7221922",
"0.7147664",
"0.71429825",
"0.7118888",
"0.70629704",
"0.6752796",
"0.66929615",
"0.6688346",
"0.6648492",
"0.6215986",
"0.6196026",
"0.5947612",
"0.5741585",
"0.57392573",
"0.57115555",
"0.5514564",
"0.5501918",
"0.5449907",
"0.5414745... | 0.7699924 | 0 |
Set pulse on hit and enable and release and disable rule on driver. Pulses a driver when a switch is hit. Then enables the driver (may be with pwm). When the switch is released the pulse is canceled and the driver becomes disabled. When the eos_switch is hit the pulse is canceled and the driver becomes enabled (likely ... | def set_pulse_on_hit_and_enable_and_release_and_disable_rule(self, enable_switch: SwitchSettings,
eos_switch: SwitchSettings, coil: DriverSettings,
repulse_settings: Optional[RepulseSettings... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pulse_on_hit_and_release_and_disable_rule(self, enable_switch: SwitchSettings,\n eos_switch: SwitchSettings, coil: DriverSettings,\n repulse_settings: Optional[RepulseSettings]):\n raise NotImpl... | [
"0.7572105",
"0.7389231",
"0.72445816",
"0.72229266",
"0.71529543",
"0.70727235",
"0.7035159",
"0.680837",
"0.6792148",
"0.6716168",
"0.66067076",
"0.6274268",
"0.62019145",
"0.59817576",
"0.5790895",
"0.57747394",
"0.57251734",
"0.5636799",
"0.55792576",
"0.5506547",
"0.5428... | 0.75235784 | 1 |
Add a callback for when the given future has been resolved. | def on_future(self, _future, _callback, *_args, **_kwargs):
callback = functools.partial(self._do_on_future, _callback, _args, _kwargs)
# Create timeout handler and regular handler.
self._future_timeouts[_future] = self.schedule_in(self.future_timeout, callback)
future.add_done_callback... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_done_callback(self, fn):\n if self.done():\n fn(self)\n else:\n self._callbacks.append(fn)",
"def add_done_callback(self, callback):\n with self._done_condition:\n if self._state in [PENDING, RUNNING]:\n self._done_callbacks.append(call... | [
"0.66994846",
"0.659744",
"0.65294266",
"0.6440456",
"0.6353762",
"0.6231799",
"0.61494493",
"0.609444",
"0.6058158",
"0.6058149",
"0.60350883",
"0.5960157",
"0.58498746",
"0.5810766",
"0.5760717",
"0.5746292",
"0.5733729",
"0.57289726",
"0.5723052",
"0.5710217",
"0.5679256",... | 0.7139849 | 0 |
Schedule a callback to be ran as soon as possible in this loop. Will return an opaque handle that can be passed to `unschedule` to unschedule the function. | def schedule(self, _callback, *_args, **_kwargs):
@coroutine
@functools.wraps(_callback)
def inner():
_callback(*_args, **_kwargs)
return self.schedule_async(inner()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schedule_callback(self, deferred, func, *args, **kwargs):\n self.increment_pc()\n saved_pc = self.program_counter[:]\n\n @wrapper(func)\n def callback_wrapper(*args, **kwargs):\n \"\"\"Wrapper for a callback which ensures a correct PC.\"\"\"\n try:\n ... | [
"0.60958743",
"0.60066116",
"0.5989754",
"0.5935567",
"0.59139556",
"0.59139556",
"0.5760046",
"0.5744529",
"0.57212853",
"0.5630919",
"0.56135505",
"0.5577264",
"0.55720043",
"0.5535715",
"0.55142754",
"0.54844826",
"0.5457211",
"0.5456132",
"0.54463506",
"0.5429597",
"0.537... | 0.70464694 | 0 |
Schedule a callback to be ran as soon as possible after `when` seconds have passed. Will return an opaque handle that can be passed to `unschedule` to unschedule the function. | def schedule_in(self, _when, _callback, *_args, **_kwargs):
if isinstance(_when, datetime.timedelta):
_when = _when.total_seconds()
@coroutine
@functools.wraps(_callback)
def inner():
yield from asyncio.sleep(_when)
_callback(*_args, **_kwargs)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schedule_async_in(self, _when, _callback):\n if isinstance(_when, datetime.timedelta):\n _when = _when.total_seconds()\n\n @coroutine\n @functools.wraps(_callback)\n def inner():\n yield from asyncio.sleep(_when)\n yield from _callback\n\n ret... | [
"0.71576685",
"0.5960168",
"0.5606114",
"0.5550319",
"0.53337073",
"0.5309692",
"0.52763116",
"0.5262237",
"0.5249111",
"0.52373374",
"0.52373374",
"0.5199952",
"0.5189032",
"0.5167308",
"0.51216036",
"0.50948286",
"0.5093543",
"0.5088659",
"0.50886077",
"0.5082117",
"0.50529... | 0.71113753 | 1 |
Schedule a coroutine to be ran as soon as possible after `when` seconds have passed. Will return an opaque handle that can be passed to `unschedule` to unschedule the function. | def schedule_async_in(self, _when, _callback):
if isinstance(_when, datetime.timedelta):
_when = _when.total_seconds()
@coroutine
@functools.wraps(_callback)
def inner():
yield from asyncio.sleep(_when)
yield from _callback
return self.schedu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schedule_in(self, _when, _callback, *_args, **_kwargs):\n if isinstance(_when, datetime.timedelta):\n _when = _when.total_seconds()\n\n @coroutine\n @functools.wraps(_callback)\n def inner():\n yield from asyncio.sleep(_when)\n _callback(*_args, **_k... | [
"0.6846653",
"0.5696773",
"0.5445648",
"0.52606493",
"0.5258912",
"0.5141864",
"0.51307636",
"0.51307636",
"0.5117959",
"0.51097524",
"0.50966895",
"0.49681464",
"0.49460042",
"0.48996404",
"0.4890596",
"0.48783326",
"0.4865467",
"0.48385656",
"0.48357123",
"0.48107603",
"0.4... | 0.6915283 | 0 |
Schedule a callback to be ran every `interval` seconds. Will return an opaque handle that can be passed to unschedule() to unschedule the interval function. A function will also stop being scheduled if it returns False or raises an Exception. | def schedule_periodically(self, _interval, _callback, *_args, **_kwargs):
if isinstance(_interval, datetime.timedelta):
_interval = _interval.total_seconds()
@coroutine
@functools.wraps(_callback)
def inner():
while True:
yield from asyncio.sleep(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schedule_async_periodically(self, _interval, _callback, *_args, **_kwargs):\n if isinstance(_when, datetime.timedelta):\n _when = _when.total_seconds()\n\n @coroutine\n @functools.wraps(_callback)\n def inner():\n while True:\n yield from asyncio... | [
"0.7611171",
"0.72958636",
"0.7202084",
"0.7022559",
"0.7002948",
"0.66986394",
"0.6679216",
"0.66536695",
"0.6628146",
"0.6450473",
"0.6406166",
"0.63929296",
"0.6314753",
"0.62664723",
"0.6221932",
"0.61743444",
"0.6099458",
"0.60735184",
"0.5877573",
"0.58319503",
"0.58273... | 0.79773027 | 0 |
Return whether or not the given handle is still scheduled. | def is_scheduled(self, handle):
return not handle.cancelled() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_scheduled(self) -> bool:\n return not self.terminated and self.__state != Process.IDLE",
"async def timer_running(self, handle: str) -> bool:\n name = self.name\n self.logger.debug(\"Checking timer with handle %s for %s\", handle, self.name)\n return self.AD.sched.timer_running... | [
"0.7325243",
"0.72793305",
"0.6534397",
"0.64810956",
"0.6426111",
"0.63666165",
"0.63640743",
"0.6350375",
"0.6290454",
"0.627354",
"0.6244751",
"0.6230844",
"0.62235695",
"0.6197638",
"0.61975336",
"0.61951977",
"0.61813676",
"0.615372",
"0.614175",
"0.61378837",
"0.6070022... | 0.8905771 | 0 |
Run until future is resolved. | def run_until(self, future):
@coroutine
def inner():
yield from future
self._unschedule_all()
self.loop.run_until_complete(asyncio.ensure_future(inner())) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def wait_until_done(self) -> None:\n ...",
"async def wait_async(self):\n await self._future",
"def run_until_complete(self, future, timeout=None): # NEW!\r\n assert isinstance(future, Future)\r\n\r\n signal = threading.Condition()\r\n if timeout is None:\r\n ... | [
"0.7302693",
"0.7098596",
"0.69729954",
"0.68908244",
"0.6339196",
"0.6339196",
"0.6339196",
"0.6339196",
"0.63155216",
"0.6311712",
"0.6283957",
"0.6271067",
"0.6271067",
"0.6271067",
"0.6271067",
"0.6271067",
"0.6271067",
"0.6271067",
"0.6271067",
"0.6271067",
"0.6238508",
... | 0.7688761 | 0 |
Take a nuke node, such as a read node or a Cryptomatte gizmo, and Reformat metadata into a dictionary, and collect channel information. | def __init__(self, node_in):
self.cryptomattes = {}
self.nuke_node = node_in
self.selection = None
if not node_in:
return
exr_metadata_dict = node_in.metadata() or {}
prefix = "exr/cryptomatte/"
default_selection = None
for key, value in exr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nodes(self, irc, msg, args, channel):\n pie = self.instances[irc.network]\n irc.reply([str(x) for x in pie.graphs[channel].nodes.values()])",
"async def info(ctx):\n server = ctx.message.guild\n name = server.name\n owner = server.owner\n creation_date = server.created_at\n ... | [
"0.49682045",
"0.4965133",
"0.48950648",
"0.48330873",
"0.47763747",
"0.47557113",
"0.4672016",
"0.46068865",
"0.45688218",
"0.4524178",
"0.4506004",
"0.44435894",
"0.44433522",
"0.442099",
"0.43905738",
"0.43887165",
"0.43723145",
"0.43646377",
"0.4338512",
"0.43365788",
"0.... | 0.5142253 | 0 |
Checks that the selection is valid. | def is_valid(self):
if self.selection is None:
return False
if self.selection not in self.cryptomattes:
return False
if "channels" not in self.cryptomattes[self.selection]:
return False
if len(self.cryptomattes[self.selection]["channels"]) < 2:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def requires_selection(self) -> bool:\n return True",
"def validateSelection(self, exportItems):\n\n invalidItems = []\n # Look for selected items which arent of the correct type\n for item in exportItems:\n if not item.sequence() and not item.trackItem():\n invalidItems.append(item)\... | [
"0.6651532",
"0.6511238",
"0.6496035",
"0.6281323",
"0.6092379",
"0.6071178",
"0.60368043",
"0.60075337",
"0.5985491",
"0.5956918",
"0.5955037",
"0.5923048",
"0.591732",
"0.5899168",
"0.5867308",
"0.5866485",
"0.58013046",
"0.57818985",
"0.57534087",
"0.5744871",
"0.5736666",... | 0.6579121 | 1 |
sets the selection (eg. cryptoObject) based on the name. Returns true if successful. | def set_selection(self, selection):
for num in self.cryptomattes:
if self.cryptomattes[num]["name"] == selection:
self.selection = num
return True
self.selection = None
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_active(self, name):\n try:\n obj = self.get_by_name(name)\n item = obj.item\n group = self.group_items[obj.kind]\n\n group_index = self.index(group.row(), 0, QtCore.QModelIndex())\n item_index = self.index(item.row(), 0, group_index)\n\n ... | [
"0.6081402",
"0.5837094",
"0.5716215",
"0.5606648",
"0.5603318",
"0.5579458",
"0.5501297",
"0.54874736",
"0.5427308",
"0.5410648",
"0.540119",
"0.538927",
"0.53702074",
"0.5359982",
"0.53305274",
"0.5328184",
"0.53180003",
"0.5280301",
"0.5278149",
"0.5265013",
"0.5257278",
... | 0.77932 | 0 |
gets the names of the cryptomattes contained the file, which are the possible selections or cryptomatte channels. | def get_cryptomatte_names(self):
return [self.cryptomattes[x]["name"] for x in self.cryptomattes] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _identify_channels(self, name):\n\n channel_list = []\n if self.nuke_node.Class() == \"Cryptomatte\":\n # nuke_node is a keyer gizmo\n channel_list = self.nuke_node.node('Input1').channels()\n else:\n # nuke_node might a read node\n channel_list ... | [
"0.5787666",
"0.5672296",
"0.55718595",
"0.55461186",
"0.54703754",
"0.5463261",
"0.5390272",
"0.53667766",
"0.5364245",
"0.53621876",
"0.5335746",
"0.5329547",
"0.5319464",
"0.52820706",
"0.5278067",
"0.5262054",
"0.52222556",
"0.5201887",
"0.5199541",
"0.5195934",
"0.515800... | 0.6824994 | 0 |
from a name like "cryptoObject", gets sorted channels, such as cryptoObject, cryptoObject00, cryptoObject01 | def _identify_channels(self, name):
channel_list = []
if self.nuke_node.Class() == "Cryptomatte":
# nuke_node is a keyer gizmo
channel_list = self.nuke_node.node('Input1').channels()
else:
# nuke_node might a read node
channel_list = self.nuke_nod... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ordered_channel_names(self):\n channel_list = []\n for k in self.__dict__.keys():\n if k.startswith('channel_'):\n channel_list.append(\n [int(k.split('channel_')[1]), self.__dict__[k]]\n )\n channel_list.sort()\n if le... | [
"0.70834565",
"0.6133864",
"0.56112415",
"0.5569978",
"0.52664435",
"0.52664435",
"0.52457845",
"0.5231811",
"0.5229068",
"0.5212763",
"0.5126728",
"0.5124537",
"0.5118637",
"0.5082058",
"0.50327605",
"0.5009194",
"0.49724874",
"0.49594697",
"0.495632",
"0.49303198",
"0.49223... | 0.615348 | 1 |
Loads json manifest and unpacks hex strings into floats, and converts it to two dictionaries, which map IDs to names and vice versa. Also caches the last manifest in a global variable so that a session of selecting things does not constantly require reloading the manifest (' ~0.13 seconds for a 32,000 name manifest.') | def parse_manifest(self):
import json
import struct
num = self.selection
try:
manifest = json.loads(self.cryptomattes[num].get("manifest", "{}"))
except:
manifest = {}
from_names = {}
from_ids = {}
unpacker = struct.Struct('=f')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_manifest(manifest_path):\n with open(manifest_path, 'r') as f:\n data = f.read()\n if data:\n return json.loads(data)\n else:\n return {}",
"def _load_manifest(self, filename: Optional[str] = None) -> Dict[str, str]:\n filename = filename or self.man... | [
"0.59855336",
"0.5957822",
"0.58551866",
"0.55946296",
"0.55939585",
"0.5585546",
"0.5535755",
"0.5527503",
"0.5448784",
"0.5435914",
"0.5383605",
"0.537182",
"0.537182",
"0.5306866",
"0.5273999",
"0.524797",
"0.5237274",
"0.5165407",
"0.5143346",
"0.51091653",
"0.51021844",
... | 0.72977996 | 0 |
Testing function to check for implementation errors and hash collisions. Checks all names and values in the manifest in the manifest by rehashing them, to ensure that the entire process is sound. Also finds collisions. Returns a tuple of errors and collisions. | def test_manifest(self):
self.parse_manifest()
ids = {}
errors = []
collisions = []
manifest = self.cryptomattes[self.selection]["names_to_IDs"]
for name, idvalue in manifest.iteritems():
if mm3hash_float(name) != idvalue:
errors.append("compu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DoCheckManifestTest(self, fail_mismatched_block_size, fail_bad_sigs,\n fail_mismatched_oki_ori, fail_bad_oki, fail_bad_ori,\n fail_bad_nki, fail_bad_nri, fail_old_kernel_fs_size,\n fail_old_rootfs_fs_size, fail_new_kernel_fs_size,\n ... | [
"0.6299262",
"0.60119635",
"0.5949086",
"0.58008045",
"0.57777554",
"0.57768065",
"0.568363",
"0.56668353",
"0.56551546",
"0.5612662",
"0.55293757",
"0.551588",
"0.55115753",
"0.55038774",
"0.54876107",
"0.54841405",
"0.5482515",
"0.54822046",
"0.5422499",
"0.54187906",
"0.54... | 0.7577914 | 0 |
Make a connection to another endpoint and return a ConnectionId for it. You can send messages on this ConnectionId immediately. | def connect(self, endpoint: Endpoint) -> ConnectionId:
if not self.started:
raise Exception(f"Bus {self.busIdentity} is not active")
endpoint = Endpoint(endpoint)
with self._lock:
connId = self._newConnectionId()
self._connIdToOutgoingEndpoint[connId] = endp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(self, connectionParams) :\n conn = RemoteConnection(connectionParams)\n\n # Generate a unique id by which to refer to this connection in the future\n id = str(uuid.uuid1())\n\n self.remoteConnections[id] = conn\n return id",
"def create_connection(\n self,... | [
"0.6547448",
"0.64600074",
"0.63099647",
"0.6295127",
"0.62183815",
"0.61354405",
"0.59780264",
"0.59573513",
"0.5940008",
"0.59051204",
"0.58524",
"0.58322716",
"0.58006173",
"0.57918835",
"0.5767221",
"0.57654315",
"0.57045084",
"0.57021475",
"0.57021475",
"0.5698933",
"0.5... | 0.7308499 | 0 |
Schedule a callback to fire on the message read thread. Use 'delay' or 'atTimestamp' to decide when the callback runs, or use neither to mean 'immediately'. You can't use both. | def scheduleCallback(self, callback, *, atTimestamp=None, delay=None):
if callback is None:
self._logger.warning("Cannot scheduleCallback(None); discarding.")
# This would cause the event loop thread to terminate
return
if atTimestamp is not None and delay is not Non... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call_later(self, delay, callback):\n reactor.callFromThread(reactor.callLater, delay, callback)",
"def call_later(self, delay, callback):\n reactor.callLater(delay, callback)",
"def _call_later(self, delay, callback):\n self.io_loop.call_later(delay, callback)",
"def run_after_delay(... | [
"0.61164474",
"0.60866094",
"0.60417444",
"0.53039217",
"0.5299968",
"0.5269826",
"0.51456463",
"0.5127129",
"0.508833",
"0.50769556",
"0.5021864",
"0.5014233",
"0.49564296",
"0.49563497",
"0.49330074",
"0.49227577",
"0.49190187",
"0.4907367",
"0.48957562",
"0.48859304",
"0.4... | 0.61563295 | 0 |
Schedule an event to get sent to the onEvent callback on the input loop | def _scheduleEvent(self, event):
self._eventsToFireQueue.put(event)
assert os.write(self._eventToFireWakePipe[1], b" ") == 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_input(self, event):\n self.update_timeval()\n self.events = []\n code = self._get_event_key_code(event)\n\n if code in self.codes:\n new_code = self.codes[code]\n else:\n new_code = 0\n event_type = self._get_event_type(event)\n valu... | [
"0.6275396",
"0.62038547",
"0.60986376",
"0.60479087",
"0.5983007",
"0.5967989",
"0.5935694",
"0.5927004",
"0.5906138",
"0.58961374",
"0.585495",
"0.5826788",
"0.581383",
"0.5796444",
"0.5790609",
"0.57666177",
"0.5715084",
"0.56671846",
"0.56589913",
"0.5647515",
"0.5647162"... | 0.63556486 | 0 |
Our select loop indicated 'socketWithData' has data pending. | def _handleReadReadySocket(self, socketWithData):
if socketWithData is self._acceptSocket:
try:
newSocket, newSocketSource = socketWithData.accept()
except OSError as exc:
# e.g., OSError: [Errno 24] Too many open files
self._logger.info(f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def poll_data(self):\n with s.socket(s.AF_INET, s.SOCK_DGRAM) as sock:\n sock.bind(('', self.__port))\n while True:\n message, address = sock.recvfrom(1024)\n self.__address = address\n logging.debug('Received: {}'.format(message))\n ... | [
"0.64880186",
"0.6481812",
"0.64238644",
"0.62901354",
"0.61899686",
"0.6123691",
"0.6109674",
"0.6109674",
"0.60701644",
"0.606652",
"0.60222965",
"0.6005148",
"0.59990996",
"0.5927602",
"0.5922998",
"0.59135413",
"0.58800566",
"0.58775216",
"0.58682287",
"0.58518314",
"0.58... | 0.6618068 | 0 |
Socket 'writeable' can accept more bytes. | def _handleWriteReadySocket(self, writeable):
if writeable not in self._socketToBytesNeedingWrite:
return
try:
bytesWritten = writeable.send(self._socketToBytesNeedingWrite[writeable])
except ssl.SSLWantReadError:
bytesWritten = -1
except ssl.SSLWan... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_write_needed(self, nbytes, underflow):",
"def ReceiveBufferSize(self) -> int:",
"def ReceiveBufferSize(self) -> int:",
"def SendBufferSize(self) -> int:",
"def SendBufferSize(self) -> int:",
"def writable(self):\n return self.append_connect or (self.append_send_buffer)",
"def writable(sel... | [
"0.6269928",
"0.62377745",
"0.62377745",
"0.6100103",
"0.6100103",
"0.59965086",
"0.59965086",
"0.5949343",
"0.59197575",
"0.59163684",
"0.58904225",
"0.5877699",
"0.5872574",
"0.5820368",
"0.5811556",
"0.5802184",
"0.58004016",
"0.5764541",
"0.57305753",
"0.5728187",
"0.5725... | 0.6564836 | 0 |
Iterate over the items in the wishlist and get the products from the database. | def __iter__(self):
product_ids = self.wishlist.keys()
products = Product.objects.filter(id__in=product_ids)
for product in products:
self.wishlist[str(product.id)]['product'] = product
for item in self.wishlist.values():
yield item | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n products_ids = self.wishlist.keys()\n # get the products objects and add them to the wishlist\n products = Product.objects.filter(id__in=products_ids)\n\n wishlist_session = self.wishlist.copy()\n wishlist = {}\n for product in products:\n ... | [
"0.73702574",
"0.6923004",
"0.6526089",
"0.6503565",
"0.64888847",
"0.6464952",
"0.6314977",
"0.62624204",
"0.62511605",
"0.6215542",
"0.6153764",
"0.61509013",
"0.6129298",
"0.6076732",
"0.604918",
"0.60109943",
"0.59867036",
"0.59783274",
"0.595691",
"0.59493494",
"0.593945... | 0.74418205 | 0 |
Add or remove a product to the wishlist or update its quantity. | def add_remove(self, product):
product_id = str(product.id)
if product_id not in self.wishlist:
self.wishlist[product_id] = {'price': str(product.price_in_dollars)}
else:
del self.wishlist[product_id]
self.save() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, product):\n product_id = str(product.id)\n self.wishlist[product_id] = {'price': str(product.price)}\n self.save()",
"def add_to_wishlist(request, product_id):\n product = get_object_or_404(Product, pk=product_id)\n wishlist = get_object_or_404(Wishlist, user=request.user... | [
"0.7479784",
"0.7347317",
"0.7177983",
"0.7005374",
"0.68797404",
"0.681493",
"0.6800347",
"0.6763431",
"0.6707623",
"0.66252685",
"0.66090685",
"0.6464602",
"0.644463",
"0.64385396",
"0.63563824",
"0.6327167",
"0.6306546",
"0.6236816",
"0.6137776",
"0.6130651",
"0.6107709",
... | 0.7711961 | 0 |
Permute elements of a tensor along a dimension `dim`. If permutation is None do nothing. | def apply_permutation(tensor: Tensor, dim: int, permutation: Optional[Tensor]):
if permutation is None:
return tensor
return tensor.index_select(dim, permutation) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permute(p, dims, perm):\n if issparse(p):\n return _permute_sparse(p, dims, perm)\n return _permute_dense(p, dims, perm)",
"def permute(x, order=None):\n ndims = len(x.shape)\n if order is None:\n raise ValueError(\"Permute: Order must be specified.\")\n\n if order.__class__ == l... | [
"0.67399627",
"0.6282171",
"0.6174553",
"0.6107188",
"0.6091974",
"0.604093",
"0.5971631",
"0.5741166",
"0.5669643",
"0.56401783",
"0.5604093",
"0.5555404",
"0.5337477",
"0.5284809",
"0.5278606",
"0.52729297",
"0.5257068",
"0.5256239",
"0.5248782",
"0.5200968",
"0.5109756",
... | 0.7508003 | 0 |
Iterate through all the layers and through all directions within each layer. Arguments should be listlike of length ``num_layers num_directions`` where each element corresponds to (layer, direction) pair. The corresponding elements of each of these lists will be iterated over. | def iterate_layers(self, *args):
for layer in range(self.num_layers):
yield layer, (
(
direction,
tuple(arg[self.num_directions * layer + direction] for arg in args),
)
for direction in range(self.num_directions)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self) -> Iterable[\"AbstractLane\"]:\n for origin in self.graph:\n for destination in self.graph[origin]:\n for index, lane in self.graph[origin][destination].items():\n yield lane",
"def step(self):\n for layer in self.layers:\n ... | [
"0.56702995",
"0.5390838",
"0.51307994",
"0.51242316",
"0.5109984",
"0.5058537",
"0.5057159",
"0.4929793",
"0.49037892",
"0.49035177",
"0.48847336",
"0.48763973",
"0.4873756",
"0.4857415",
"0.48254174",
"0.48151118",
"0.4796563",
"0.47938234",
"0.4784105",
"0.477571",
"0.4763... | 0.7397223 | 0 |
Scale Flickr url_s image to fit Folium popup. Popup shape is hardcoded as `self.popup_width` in both length and height. Function rescales so that the long axis exactly fits within this box. | def scale_image_to_frame(self, width, height):
aspect = width / height
# Image is landscape.
if aspect >= 1:
scale = self.popup_width / width
return (self.popup_width, int(scale * height))
# Otherwise image is portrait.
scale = self.popup_width / height
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale_widget_to_image_size(self):\n if self._image is not None:\n im = self._image.make_image()\n self.width = im.shape[1]\n self.height = im.shape[0]",
"def zoom_to_size(self, *p):\n\t\tif self.image is None or self.allocation is None:\n\t\t\treturn\n\t\tif __debug__:... | [
"0.5512757",
"0.54284984",
"0.530285",
"0.5234716",
"0.5216585",
"0.5185741",
"0.517777",
"0.5155664",
"0.5120164",
"0.5117348",
"0.5089344",
"0.50772893",
"0.5074432",
"0.50080764",
"0.4998123",
"0.4992161",
"0.4959421",
"0.49268898",
"0.49229434",
"0.4913981",
"0.48858967",... | 0.6120272 | 0 |
Set the lowest four bits of all the 16 bits tiff file in a folder to zero. | def tiff_low_four_bits_set_zero(path_tiff_source, path_tiff_out):
dir = glob.glob(path_tiff_source + '\\' + '*.tiff')
for source_file in dir:
tif = TIFF.open(source_file, mode='r')
img = tif.read_image()
img = img - img % 16 #lowest four bits set zero
img_name = os.path.basenam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\n self.all_files_idx = np.arange(self._div*self._nb_dir)\n\n if self.shuffle>1:\n np.random.shuffle(self.all_files_idx)\n\n self.idx_folder = self.all_files_idx//self._div\n self.idx_file = self.all_files_idx % self._div\n self.current_folder = self.id... | [
"0.5840278",
"0.57339275",
"0.5498971",
"0.54269385",
"0.5342206",
"0.52571565",
"0.52047503",
"0.5122611",
"0.5109874",
"0.5103661",
"0.5101632",
"0.50586116",
"0.50525945",
"0.5020488",
"0.49911335",
"0.4984211",
"0.49590093",
"0.49564266",
"0.49439636",
"0.49412417",
"0.49... | 0.7614919 | 0 |
This function splits one 16bits tiff file to two different 8bits tiff files. The strategy of split is setting the lowest 8 bits of the source 16 bits file as the pixel value of one split file and the same as the highest 8 bits. | def tiff_split(path_tiff_source, path_tiff_out):
path_out_low = path_tiff_out + '\\' + 'low8bits'
path_out_hig = path_tiff_out + '\\' + 'high8bits'
path_out_list=[path_out_hig,path_out_low]
makdir(path_out_low)
makdir(path_out_hig)
for file in glob.glob(path_tiff_source + '\\' + '*.tiff'):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split(bin_lid):\n resolvers = resolver.parse_stream(RESOLVER)\n suffixes = ['_cfa_' + camera for camera in 'LR']\n outdirs = [scratch(bin_lid,bin_lid + suffix) for suffix in suffixes]\n for od in outdirs:\n mkdirs(od)\n imagenames = list(list_images(bin_lid))\n (h,w)=(None,None)\n t... | [
"0.5542672",
"0.55242944",
"0.5498628",
"0.543143",
"0.54110205",
"0.53161323",
"0.5312914",
"0.5309105",
"0.5258685",
"0.5163846",
"0.5151364",
"0.5114061",
"0.51118064",
"0.5084054",
"0.50608444",
"0.5029268",
"0.49768984",
"0.49599314",
"0.4956773",
"0.49552044",
"0.495480... | 0.6982899 | 0 |
unblock the given ip | def unblock_ip_view(request, ip):
if request.method == 'POST':
unblock_ip(ip)
return HttpResponseRedirect(reverse("defender_blocks_view")) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unblock_ip(ip, logger, dashboard_log, firewall_ip_and_port):\n try:\n request = requests.delete(f\"http://{firewall_ip_and_port}/firewall/{ip}\")\n if not request.ok:\n logger.error(f\"Unblocking IP {ip} was unsuccessful. Code {request.status_code}\")\n dashboard_log.appe... | [
"0.754202",
"0.7157946",
"0.67682874",
"0.67535746",
"0.65734464",
"0.646841",
"0.64320874",
"0.638271",
"0.6320117",
"0.6222433",
"0.6198811",
"0.6190392",
"0.6181117",
"0.60549074",
"0.6036554",
"0.6029521",
"0.6020202",
"0.5999968",
"0.59976965",
"0.59874886",
"0.589189",
... | 0.76020145 | 0 |
unblock he given username | def unblock_username_view(request, user_id):
if request.method == 'POST':
username = User.objects.get(id=user_id).username
unblock_username(username)
log_user_unlock.send(sender=unblock_username_view, request=request, username=username)
return HttpResponse(json.dumps({"status": "unlo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unblock(user_id):\n user = User.query.filter_by(id=user_id).first()\n if not user:\n raise ObjectNotFound(\"This user does not exist\")\n\n user.unblock()\n return jsonify(message='User account succesfully unblocked'), 201",
"async def unban(self, ctx, name: str):\n try:\n ... | [
"0.72230184",
"0.7210059",
"0.71730417",
"0.7066073",
"0.67244923",
"0.65640134",
"0.6544314",
"0.6491108",
"0.64267445",
"0.6417066",
"0.6388073",
"0.63744146",
"0.63177145",
"0.6310767",
"0.62980276",
"0.6290632",
"0.6267844",
"0.62429726",
"0.62315124",
"0.62009305",
"0.61... | 0.7502431 | 0 |
Returns adapter implementing the ICAVLService interface using CAVL_SERVICE setting | def get_cavl_service() -> ICAVLService:
try:
return import_string(settings.CAVL_SERVICE)()
except ImportError as e:
msg = "Could not import '%s' for API setting 'CAVL_SERVICE'. %s: %s." % (
settings.CAVL_SERVICE,
e.__class__.__name__,
e,
)
rais... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_adapter(self):\n\t\timportlib.import_module('app.adapters.{0}'.format(self.builder.name))\n\n\t\tclasses = inspect.getmembers(\n\t\t\tsys.modules['app.adapters.{0}'.format(self.builder.name)],\n\t\t\tinspect.isclass\n\t\t)\n\n\t\tadapter = next(\n\t\t\tcls_ for cls_ in classes \\\n\t\t\tif hasattr(cls_[1],... | [
"0.557375",
"0.54590374",
"0.5451513",
"0.5436211",
"0.5365986",
"0.5205334",
"0.5173588",
"0.51281923",
"0.5052206",
"0.4985571",
"0.49650833",
"0.49015048",
"0.4838178",
"0.47969443",
"0.47782078",
"0.47619662",
"0.47539312",
"0.46973038",
"0.46862763",
"0.46629298",
"0.462... | 0.7333546 | 0 |
Returns adapter implementing INotification interface using NOTIFIER setting | def get_notifications() -> INotifications:
notifiers = {"django": DjangoNotifier, "govuk-notify": GovUKNotifyEmail}
notifier = getattr(settings, "NOTIFIER", "django")
notifier_class = notifiers[notifier]
return notifier_class() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_notifier(publisher_id):\n global NOTIFIER\n return NOTIFIER.prepare(publisher_id=publisher_id)",
"def notifier(self, name):\n\n # Look up the notifier\n notifier = self.notifiers.get(name, self.notifiers.get(None))\n\n # Return the driver\n return notifier.driver",
"de... | [
"0.66353315",
"0.5884832",
"0.5845214",
"0.5780354",
"0.5691237",
"0.5644371",
"0.5612159",
"0.55944556",
"0.5469027",
"0.5379494",
"0.5379494",
"0.5340072",
"0.5338836",
"0.52982986",
"0.52318954",
"0.52235496",
"0.5178805",
"0.51663077",
"0.5131492",
"0.51082945",
"0.510615... | 0.65746456 | 1 |
saveAsim(samplePt, obj_animatLabModel, fldrSimFiles, ix, indexLen, verbose=3) samplePt Dict of simulation parameters to update with key as [element name].[element property] obj_animatLabModel AnimatLabModel object to update fldrSimFiles Folder path where simulation files are saved ix Incremented file index to avoid ove... | def saveAsim(samplePt, obj_animatLabModel, fldrSimFiles, ix, indexLen=3, verbose=3):
#cols = ['ERROR']
cols = []
basename = os.path.split(obj_animatLabModel.asimFile)[-1].split('.')[0]
saveFile = {}
# Generate new .asim file name
filename = basename + '-' + str(ix+1).zfill(indexLen) + '.a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _save_mayavi_figure(self, fig, filename, azimuth=153, elevation=62,\n distance=400, focalpoint=[25., 63., 60.], aa=16,\n size=(1024, 1024)):\n scene = fig.scene\n\n scene.anti_aliasing_frames = aa\n\n mlab.view(azimuth=azimuth, elevatio... | [
"0.5425702",
"0.5371059",
"0.53118604",
"0.5278772",
"0.52680564",
"0.5233465",
"0.51136476",
"0.50579697",
"0.5051095",
"0.5047712",
"0.50206965",
"0.50204813",
"0.4988163",
"0.49863473",
"0.49829757",
"0.4980291",
"0.49471554",
"0.4935383",
"0.49254158",
"0.49232134",
"0.48... | 0.87497056 | 0 |
__init__(projName, obj_aproj=None, obj_simRunner=None, obj_simSet=None) Initiate ProjectManager object projName Unique name for ProjectManager object obj_aproj AnimatLabModel object obj_simrunner SimRunner object | def __init__(self, projName, obj_aproj=None, obj_simRunner=None):
self.projName = projName
self.activityLog = {}
self.errorLog = {}
if (type(obj_aproj) == AnimatLabModel) or (obj_aproj is None):
self.aproj = obj_aproj
else:
raise TypeErro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, main_params, projs):\n self.__dict__ = vars(main_params)\n self.projs = projs\n self.proj, self.model, self.var, self.region = (\n self.str_to_aospy_iterable(main_params.proj, main_params.model,\n main_params.var, main_params.... | [
"0.6410015",
"0.6122314",
"0.6073041",
"0.6057213",
"0.59716004",
"0.5962218",
"0.5923332",
"0.59220415",
"0.58743334",
"0.5863776",
"0.58579",
"0.5841253",
"0.5841239",
"0.5840288",
"0.5816639",
"0.5808202",
"0.5787629",
"0.57743895",
"0.57699895",
"0.5768949",
"0.57636404",... | 0.8615024 | 0 |
set_aproj(obj_aproj) Sets the AnimatLabModel object for the ProjectManager obj_aproj AnimatLabModel object for basis of simulations | def set_aproj(self, obj_aproj):
if type(obj_aproj) == AnimatLabModel:
self.aproj = obj_aproj
else:
raise TypeError("obj_aproj must be an AnimatLabModel object!") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, projName, obj_aproj=None, obj_simRunner=None):\n \n self.projName = projName\n self.activityLog = {}\n self.errorLog = {}\n \n if (type(obj_aproj) == AnimatLabModel) or (obj_aproj is None):\n self.aproj = obj_aproj\n else:\n ... | [
"0.63675725",
"0.54510826",
"0.51495695",
"0.5112119",
"0.5112119",
"0.5082331",
"0.5074758",
"0.49699888",
"0.49410748",
"0.49406776",
"0.49163842",
"0.48847675",
"0.4861831",
"0.48597294",
"0.48274288",
"0.48030266",
"0.47882882",
"0.47839254",
"0.47794473",
"0.477288",
"0.... | 0.8719895 | 0 |
set_simRunner(obj_simRunner) Sets the simRunner object for the ProjectManager obj_simRunner SimulationRunner object for organizing simulations | def set_simRunner(self, obj_simRunner):
if type(obj_simRunner) == AnimatLabSimulationRunner:
self.simRunner = obj_simRunner
else:
raise TypeError("obj_simRunner must be an AnimatLabSimulationRunner object!") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setSimulation(self, simulation):\r\n raise NotImplementedError()",
"def run_simulator(self):\n\n self.update_settings()\n\n # Pass in the progress bar and the master so that the simulator can\n # update the progress bar and then refresh the screen when the progress\n # chec... | [
"0.57825583",
"0.5381525",
"0.535339",
"0.5258198",
"0.51377577",
"0.5133689",
"0.50597525",
"0.50033647",
"0.49955642",
"0.49677426",
"0.49385235",
"0.48960555",
"0.48833895",
"0.48766336",
"0.48765796",
"0.48746789",
"0.48729342",
"0.48449382",
"0.48236495",
"0.4810407",
"0... | 0.87587506 | 0 |
make_asims(obj_simSet) obj_simSet SimulationSet object used to generate parameter combinations DESCRIPTION Generates .asim files used as the basis for AnimatLab simulations based on the parameter dictionary formatted by obj_simSet. | def make_asims(self, obj_simSet):
if type(obj_simSet) is not SimulationSet:
raise TypeError("obj_simSet must be a SimulationSet object!")
cols = ['FileName']
saveFiles = {}
# Calculate size of text buffer for naming files
countLength = len(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createArmySims(self):\n # create army sims for player\n for systemID in self.game.myArmies.keys():\n self.createPlayerArmySim(systemID)\n \n # create army sims representing other empires\n for systemID in self.game.otherArmies.keys():\n self.createOtherA... | [
"0.55694175",
"0.54515797",
"0.5435121",
"0.54233396",
"0.5224288",
"0.5181293",
"0.51750064",
"0.51612604",
"0.51083934",
"0.51014996",
"0.5083064",
"0.50465715",
"0.5015743",
"0.49896726",
"0.49784303",
"0.49782255",
"0.4967333",
"0.4945393",
"0.49368885",
"0.48952085",
"0.... | 0.70615596 | 0 |
run(cores=1) cores Number of cores to use to run simulations. None >> Run simulations in serial (longest time) + [] >> Use up to [] of cores 1 >> Use ALL CPU cores DESCRIPTION ProjectManager.run() is a simple interface function that runs AnimatLab simulations. The cores argument is passed to the simulationRunner class,... | def run(self, cores=-1):
self.simRunner.do_simulation(cores=cores)
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n run_simulation(spectral=False, ml=False, num_procs=1)\n run_simulation(spectral=True, ml=False, num_procs=1)\n run_simulation(spectral=False, ml=True, num_procs=1)\n run_simulation(spectral=True, ml=True, num_procs=1)\n run_simulation(spectral=False, ml=True, num_procs=10)\n run_sim... | [
"0.64820915",
"0.6010382",
"0.591841",
"0.58024275",
"0.58024275",
"0.57946324",
"0.5790396",
"0.57668465",
"0.5740148",
"0.56931937",
"0.5638104",
"0.5587805",
"0.5572932",
"0.55053955",
"0.5466158",
"0.5466106",
"0.5464781",
"0.5447125",
"0.5446936",
"0.54381967",
"0.539055... | 0.80584097 | 0 |
m is a the message encoded as a polynomial | def encrypt(self,m):
if m._N <= self._P.get_N():
r = self._P.gen_rPoly()
e = (r.scale(self._P.get_p())*self._h+m) % self._P.get_q()
return e # Polynomial representing the encryption message
else:
raise Exception("m is too large, must be equal or under si... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_mom_poly(p,m):\n # polynomial.\n pol = 1.\n for key in p.keys():\n pol += (p[key] - m[key])**2\n return pol",
"def encode(generator_polynomial, message):\n power = msb(generator_polynomial)\n message <<= power\n return message ^ divide_polynomials(polynomial1=message, polyn... | [
"0.70983243",
"0.61698157",
"0.587901",
"0.5877278",
"0.5715824",
"0.5712316",
"0.56301624",
"0.5588554",
"0.55859685",
"0.55293375",
"0.5523438",
"0.54995716",
"0.5489549",
"0.5468917",
"0.5468211",
"0.54662186",
"0.54412967",
"0.541935",
"0.5413557",
"0.5356289",
"0.5350215... | 0.7049733 | 1 |
Maps a list of strings to their shortest unique suffixes Maps all original strings to the smallest number of chunks, as specified by delim, that are not a suffix of any other original string. If the original string was a suffix of another string, map it to its unaltered self. | def _get_shortest_unique_suffix_dict(
input_str_list: List[str], delim: str = "."
) -> Dict[str, str]:
# all input strings must be unique
assert len(input_str_list) == len(set(input_str_list))
if delim == "":
raise ValueError("delim must be a non-empty string.")
suffix_dict = defaultdict(li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join_bpe(lst:list, s:str):\n\n if s[:2] == \"##\":\n # How to handle situation where first term is double hashed?\n base = lst.pop() # Remove from last position\n new_term = base + s.strip(\"#\")\n return lst + [new_term]\n return lst + [s]",
"def _repair_names_unique(\n ... | [
"0.5399903",
"0.5360808",
"0.5333351",
"0.53276676",
"0.5230604",
"0.518405",
"0.51806355",
"0.51512223",
"0.5076588",
"0.50518227",
"0.5034453",
"0.4994702",
"0.49840856",
"0.49824935",
"0.49758986",
"0.4959224",
"0.494619",
"0.49393862",
"0.4936973",
"0.4900453",
"0.4897777... | 0.72810227 | 0 |
Extract standard plots for singleobjective optimization. Extracts a list of plots from an Experiment and GenerationStrategy of general interest to an Ax user. Currently not supported are | def get_standard_plots(
experiment: Experiment, generation_strategy: Optional[GenerationStrategy]
) -> List[go.Figure]:
objective = not_none(experiment.optimization_config).objective
if isinstance(objective, MultiObjective):
logger.warning(
"get_standard_plots does not currently support... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_sample(self):\n print(u'plot_sample()')\n data_set = self.data_sets[1]\n scenario = u'Greedy Search'\n titles = [u'Collaborative Filtering', u'Content-based']\n fig, axes = plt.subplots(1, 2, figsize=(10, 5))\n for i, rec_type in enumerate(data_set.missions):\n ... | [
"0.6394151",
"0.6230003",
"0.61507076",
"0.6087635",
"0.6050366",
"0.59917736",
"0.5969156",
"0.5965259",
"0.59232706",
"0.58762634",
"0.5772327",
"0.57710993",
"0.57626706",
"0.57371104",
"0.57312965",
"0.571158",
"0.56957924",
"0.56929827",
"0.5684071",
"0.56773794",
"0.567... | 0.7944752 | 0 |
Transforms an experiment to a DataFrame. Only supports Experiment and SimpleExperiment. Transforms an Experiment into a dataframe with rows keyed by trial_index and arm_name, metrics pivoted into one row. | def exp_to_df(
exp: Experiment,
metrics: Optional[List[Metric]] = None,
run_metadata_fields: Optional[List[str]] = None,
trial_properties_fields: Optional[List[str]] = None,
**kwargs: Any,
) -> pd.DataFrame:
def prep_return(
df: pd.DataFrame, drop_col: str, sort_by: List[str]
) -> p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exp_to_df(\n exp: Experiment,\n metrics: Optional[List[Metric]] = None,\n key_components: Optional[List[str]] = None,\n **kwargs: Any,\n) -> pd.DataFrame:\n key_components = key_components or [\"trial_index\", \"arm_name\"]\n\n # Accept Experiment and SimpleExperiment\n if isinstance(exp, ... | [
"0.70922107",
"0.6628502",
"0.6381592",
"0.60324854",
"0.5789459",
"0.56973666",
"0.5482064",
"0.5477098",
"0.5394673",
"0.5329763",
"0.5311363",
"0.52702683",
"0.5265646",
"0.52604896",
"0.52600574",
"0.5229816",
"0.5196886",
"0.51170677",
"0.5105222",
"0.5060614",
"0.501846... | 0.7879921 | 0 |
Finds the optimal trial given an experiment, based on raw objective value. Returns a 1row dataframe. Should match the row of ``exp_to_df`` with the best raw objective value, given the same arguments. | def get_best_trial(
exp: Experiment,
additional_metrics: Optional[List[Metric]] = None,
run_metadata_fields: Optional[List[str]] = None,
**kwargs: Any,
) -> Optional[pd.DataFrame]:
objective = not_none(exp.optimization_config).objective
if isinstance(objective, MultiObjective):
logger.wa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def objective(self, trial):\n # Suggest start row IDs\n selected = [self.all_df.index.max()]\n for i in range(self.n_points):\n id_min = 3 * (self.n_points - len(selected) + 1)\n id_max = selected[-1] - 3\n if id_min + 3 > id_max:\n return np.inf... | [
"0.6023675",
"0.57024705",
"0.549064",
"0.5453015",
"0.53470635",
"0.5274136",
"0.49488753",
"0.48567286",
"0.4852621",
"0.48308128",
"0.47868332",
"0.47639084",
"0.47044444",
"0.46960852",
"0.46759018",
"0.46727654",
"0.46523926",
"0.465156",
"0.4637326",
"0.46021733",
"0.45... | 0.70668334 | 0 |
Display the form on get, on submission, save the uploaded pdf to the "serial" directory, and return the form populated along with the generated thumbnails. | def generate_thumbnails(self):
form = Form(PDFUploadSchema(), buttons=("submit",))
if "submit" in self.request.POST:
log.info("submit: %s", self.request.POST)
controls = self.request.POST.items()
try:
appstruct = form.validate(controls)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_pdf(submission):\n # Get questions from sections\n fields = {}\n for section in submission.questions:\n for form in section[\"forms\"]:\n for field in form[\"fields\"]:\n fs = field.get(\"fields\", [field])\n for f in fs:\n fiel... | [
"0.6528884",
"0.6424879",
"0.6307522",
"0.6126606",
"0.5985242",
"0.59249526",
"0.58687127",
"0.5807031",
"0.5754557",
"0.5734037",
"0.5708609",
"0.5695069",
"0.56741",
"0.56607753",
"0.56555784",
"0.56451267",
"0.56432295",
"0.56404954",
"0.5632161",
"0.55544764",
"0.5552934... | 0.7277283 | 0 |
Create the output filenames and generate the top and mosaic thumbnails and write them to disk. | def write_thumbnails(self, appstruct):
slugser = slugify(appstruct["serial"])
pdf_filename = "thumbnails/%s/uploaded.pdf" % slugser
top_file = "thumbnails/%s/top.png" % slugser
mos_file = "thumbnails/%s/mosaic.png" % slugser
thumg = ThumbnailGenerator(pdf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mosaic(self):\n \n if len(self.tiles) > 1:\n hdflist = sorted(glob.glob(self.fullPath + '/*.hdf'))\n for i in range(0,len(hdflist),2):\n ms = pymodis.convertmodis_gdal.createMosaicGDAL(hdfnames = [hdflist[i], hdflist[i+1]], subset = self.subset, outformat = 'G... | [
"0.6649731",
"0.6447098",
"0.6351097",
"0.63092995",
"0.6193053",
"0.61820424",
"0.61727613",
"0.6171277",
"0.6159675",
"0.61490023",
"0.6126385",
"0.610195",
"0.6096374",
"0.6060699",
"0.6001953",
"0.59990644",
"0.5988286",
"0.596851",
"0.59632564",
"0.59625936",
"0.59452736... | 0.7358759 | 0 |
Expect a binary blob of image data from wand and a filename. Write the binary blob to the file. | def save_blob(self, img_blob, filename):
out_file = open(filename, "wb")
out_file.write(img_blob)
out_file.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_img_to_fs(name, data):\n with open(name, \"wb\") as fout:\n fout.write(data)",
"def write(filename, data):\r\n with open(filename, \"wb\") as f:\r\n pic.dump(data, f)",
"def write_data(writer: UFOWriter, filename: str, data: bytes) -> None:\n writer.writeImage(filename, dat... | [
"0.65800583",
"0.64400434",
"0.64122224",
"0.6264098",
"0.61690265",
"0.6132258",
"0.6069596",
"0.60462534",
"0.60354304",
"0.5993703",
"0.5823665",
"0.5802249",
"0.573362",
"0.5722561",
"0.56572026",
"0.563467",
"0.5620268",
"0.55981404",
"0.5575564",
"0.55676",
"0.5556569",... | 0.66238785 | 0 |
Read from the file pointer, write intermediate file, and then copy to final destination. | def single_file_write(self, file_pointer, filename):
temp_file = "resources/temp_file"
file_pointer.seek(0)
with open(temp_file, "wb") as output_file:
shutil.copyfileobj(file_pointer, output_file)
os.rename(temp_file, filename)
log.info("Saved file: %s", filename) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_file(input, output):\n for f in input:\n while True:\n chunk = f.read(1024)\n if not chunk:\n break\n output.write(chunk)\n output.flush()",
"def copy_file(file, destination):\n with open(file, 'rb') as infile, open(destination, 'wb... | [
"0.6279301",
"0.6177359",
"0.58933413",
"0.58200485",
"0.5752162",
"0.57351536",
"0.56330127",
"0.5618136",
"0.5591773",
"0.5576094",
"0.5556444",
"0.5539393",
"0.5537127",
"0.5537127",
"0.5537127",
"0.5520664",
"0.5498421",
"0.5457351",
"0.5456319",
"0.5376576",
"0.53366977"... | 0.642381 | 0 |
Calculates easting, northing and coordinate precision from the station grid reference. Returns dictionary with the additional keys. | def calcStationCoords(station, gridSquares):
# calculate coordinates and precision
gridRef = station["gridReference"]
gridCode = gridRef[:2]
station["precision"] = 10 ** (5 - len(gridRef[2:])/2) # Units: meters
station["easting"] = (
gridSquares[gridCode][0] + int(gridRef[2:len(gridRef[2:]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getStandardGeoProperties():\n geoproperties = {\n 'Hsin': {\n 'tl': {\n 'lat': 21.108,\n 'long': -158.584,\n },\n 'br': {\n 'lat': 21.9,\n 'long': -157.392,\n }\n },\n 'Hsout':{\n ... | [
"0.58611155",
"0.5576505",
"0.55065113",
"0.5425901",
"0.5412877",
"0.53959215",
"0.5370489",
"0.53406626",
"0.5338572",
"0.5295297",
"0.52770424",
"0.52559906",
"0.5180949",
"0.51474416",
"0.5129869",
"0.510701",
"0.5102792",
"0.50732666",
"0.5068528",
"0.5057706",
"0.505651... | 0.6553498 | 0 |
Adds river ID to station dictionary. | def addStationRiverID(station, riverIDs):
stationID = station["id"]
riverID = riverIDs.get(stationID)
station["riverId"] = riverID
return station | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_person_to_the_station(self, line, station):\n\n if line in self.__stations_dict:\n if station in self.__stations_dict[line]:\n self.__stations_dict[line][station] += 1\n else:\n self.__stations_dict[line][station] = 1\n else:\n se... | [
"0.64741087",
"0.58891344",
"0.5817344",
"0.58151716",
"0.56741",
"0.53069776",
"0.510854",
"0.5107141",
"0.5069008",
"0.50093204",
"0.49964875",
"0.49900323",
"0.49865165",
"0.49712417",
"0.49245796",
"0.49185914",
"0.48994073",
"0.48912543",
"0.4868128",
"0.4858781",
"0.485... | 0.84891737 | 0 |
Field gain is in T/A so to get Amps we need to devide the field value by the field Gain | def set_field(coil, fieldValue, fieldGain):
current = (fieldValue/fieldGain)*1e3 # set the current to be in milliamps
print(current)
coil.current(current)
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dB2gain(dB):\n V = math.exp(dB/20)\n return V",
"def gain(self):\n return self[1]",
"def update_playback_gain(self, val):\n self.playbackGain = 10**(5.0*(val - self.speedDial.maximum()/2)/self.speedDial.maximum())",
"def microphone_transferfactor(sensitivity: float) -> float:\n a =... | [
"0.68036616",
"0.67524546",
"0.660555",
"0.6549612",
"0.643078",
"0.6416478",
"0.6324724",
"0.627394",
"0.6268708",
"0.61913145",
"0.6164041",
"0.6145486",
"0.6114966",
"0.611201",
"0.6110434",
"0.610212",
"0.60916513",
"0.6076527",
"0.60728437",
"0.5995432",
"0.596725",
"0... | 0.70014805 | 0 |
Adds a validation schema for a required object property. | def with_required_property(self, name, typ, *rules):
self.properties = self.properties if self.properties != None else []
schema = PropertySchema(name, typ)
schema.rules = rules
schema.make_required()
return self.with_property(schema) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_property_schema(self, schema):\n json_schema_path = os.path.join(_ROOT,\n 'data',\n 'property_json_schema.json')\n json_schema = load_json_or_yaml(json_schema_path)\n return validate(schema, json_schema)... | [
"0.6920623",
"0.6739063",
"0.6722102",
"0.6159456",
"0.6094306",
"0.6013235",
"0.597917",
"0.5977781",
"0.5967081",
"0.5964867",
"0.59267306",
"0.59114385",
"0.5868049",
"0.5863857",
"0.58553565",
"0.5825143",
"0.58220434",
"0.5815082",
"0.58138317",
"0.5802128",
"0.57447124"... | 0.6751664 | 1 |
Convert address to ip and prefix. | def address_to_ip_prefix(address):
return address.split('/') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_ip(addr):\n return \\\n str(ord(addr[0])) + '.' + \\\n str(ord(addr[1])) + '.' + \\\n str(ord(addr[2])) + '.' + \\\n str(ord(addr[3]))",
"def morseToPubIP(self, address):\n ip_from_morse = address[0];\n port_from_morse = address[1];\n \n ip_fr... | [
"0.682455",
"0.67066574",
"0.669897",
"0.65752935",
"0.6555434",
"0.6473585",
"0.6432157",
"0.63691694",
"0.6363774",
"0.6297581",
"0.6280675",
"0.6266919",
"0.6254692",
"0.62492925",
"0.62355924",
"0.6225235",
"0.6209515",
"0.6200921",
"0.61859864",
"0.61740637",
"0.61513656... | 0.7921652 | 0 |
Set ip addresses of all interfaces. | def set_ip_adresses(self):
# unfold a config tree for the current suffix, if any
for interface, details in self.interfaces.items():
for k, v in details.items():
if k == 'address':
ip, prefix = address_to_ip_prefix(v)
self.interfaces[int... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ips(self, ips):\n\n self._ips = ips",
"def set_all(self, host_names, ip_address):\n for host_name in host_names:\n self.set_one(host_name, ip_address)",
"def ipv4_interface_setup(self):\n\n for i in self._nodes.items():\n node = i[1]\n\n # Show the curr... | [
"0.72794324",
"0.661401",
"0.65779203",
"0.6340851",
"0.6324031",
"0.63150054",
"0.61869067",
"0.617959",
"0.61534643",
"0.6090856",
"0.6058395",
"0.600056",
"0.5943",
"0.5909638",
"0.5908889",
"0.5886598",
"0.58724004",
"0.58520234",
"0.58423156",
"0.5806767",
"0.5795594",
... | 0.74871445 | 0 |
Retrieve pci addresses for network interfaces. | def retrieve_pci_addresses(self):
debug('Retrieve PCI addresses...')
try:
lshw_json = self.run_ssh('lshw -json').stdout
except SSHError:
fatal('Cannot connect to node:', self.ip_address)
lshw = json.loads(lshw_json)
pci_addresses = []
for component... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def network_interfaces():\n try:\n command = which('ipadm')\n args = ('show-addr', '-p', '-o', 'STATE,ADDR')\n pattern = r'ok:(\\d+\\.\\d+\\.\\d+\\.\\d+)'\n except CommandMissing:\n # Fall back to old command on old solaris releases.\n command = which('/usr/sbin/ifconfig')\... | [
"0.6476282",
"0.63909584",
"0.6255508",
"0.6090838",
"0.6077904",
"0.6034055",
"0.60326415",
"0.5983117",
"0.5981854",
"0.5968475",
"0.5956649",
"0.5947739",
"0.593454",
"0.59312534",
"0.590775",
"0.5905652",
"0.5843624",
"0.5813561",
"0.58115387",
"0.57801414",
"0.57743907",... | 0.76167774 | 0 |
Generates a slope raster from the input DEM raster. | def generate_slope_raster(in_path, out_path):
cmd = "gdaldem slope -alg ZevenbergenThorne {} {}".format(in_path, out_path)
os.system(cmd) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_slope(self):\n\n # assign variables\n slope = 'slope'\n aspect = 'aspect'\n dx = 'dx'\n dy = 'dy'\n grow_slope = 'grow_slope'\n grow_aspect = 'grow_aspect'\n grow_dx = 'grow_dx'\n grow_dy = 'grow_dy'\n\n # compute slope and partial d... | [
"0.67087334",
"0.6488468",
"0.64282715",
"0.6219489",
"0.61622566",
"0.6151169",
"0.59784114",
"0.5951957",
"0.59396815",
"0.5916147",
"0.5889869",
"0.58412445",
"0.58203536",
"0.57782197",
"0.5762054",
"0.5753399",
"0.57412916",
"0.57289064",
"0.5714653",
"0.57070047",
"0.56... | 0.76822 | 0 |
Removes noise (high elevation data points like roofs, etc.) from the ground DEM raster. Replaces values in those pixels with No data Value (99999.0) | def remove_noise(ground_dem_path, out_path, ignore_value=-99999.0):
ground_np = np.array(gdal.Open(ground_dem_path).ReadAsArray())
std = ground_np[ground_np != ignore_value].std()
mean = ground_np[ground_np != ignore_value].mean()
threshold_value = mean + 1.5 * std
ground_np[ground_np >= threshold_v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform_noise_removal(mask):\n trans1 = cv.dilate(mask, KERNEL, iterations=4)\n trans1 = cv.erode(trans1, KERNEL, iterations=5)\n return cv.dilate(trans1, KERNEL, iterations=7)",
"def fix_nan(image, replace=0.):\n h = pyfits.open(image, mode='update')\n imgdata = h[0].data\n imgdata = np.where... | [
"0.64070904",
"0.6257984",
"0.61852384",
"0.61520267",
"0.5998266",
"0.5968071",
"0.5939426",
"0.5876657",
"0.58729666",
"0.5850251",
"0.58171725",
"0.5785496",
"0.57801366",
"0.5749277",
"0.5748041",
"0.57474446",
"0.5727457",
"0.57212025",
"0.5697683",
"0.5676271",
"0.56660... | 0.7533694 | 0 |
Replaces values in input rasterA with no_data_value where cell value >= threshold in rasterB | def replace_values(
rasterA_path, rasterB_path, out_path, no_data_value=-99999.0, threshold=0.98
):
cmd = 'gdal_calc.py -A {} --NoDataValue={} -B {} --outfile {} --calc="{}*(B>={}) + (A)*(B<{})"'.format(
rasterA_path,
no_data_value,
rasterB_path,
out_path,
no_data_value,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subtract(raster1, raster2):\n valid_mask = (\n (raster1 != nodata) &\n (raster2 != nodata))\n result = numpy.empty(raster1.shape, dtype=numpy.float32)\n result[:] = nodata\n result[valid_mask] = raster1[valid_mask] - raster2[valid_mask]\n return result",... | [
"0.6061164",
"0.5870934",
"0.5798967",
"0.5786439",
"0.5786439",
"0.5786439",
"0.5763308",
"0.5708147",
"0.56289405",
"0.56241614",
"0.5601261",
"0.558359",
"0.5527729",
"0.5523799",
"0.54995984",
"0.5403832",
"0.5399435",
"0.5385514",
"0.5356004",
"0.5315001",
"0.52941465",
... | 0.6994987 | 0 |
Expands holes (cells with no_data_value) in the input raster. | def expand_holes_in_raster(
in_path, search_window=7, no_data_value=-99999.0, threshold=50
):
np_raster = np.array(gdal.Open(in_path).ReadAsArray())
height, width = np_raster.shape[0], np_raster.shape[1]
for i in range(int((search_window - 1) / 2), width, 1):
for j in range(int((search_window - ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_sat_holes (data_mask, mask_value):\n\n value_sat = mask_value['saturated']\n value_satcon = mask_value['saturated-connected']\n mask_satcon = ((data_mask & value_sat == value_sat) |\n (data_mask & value_satcon == value_satcon))\n struct = np.ones((3,3), dtype=bool)\n mask_... | [
"0.6416809",
"0.6038697",
"0.6009069",
"0.59721184",
"0.5879863",
"0.58542347",
"0.57309407",
"0.5600623",
"0.5584068",
"0.5473977",
"0.5460883",
"0.5431665",
"0.54253507",
"0.53936225",
"0.53427863",
"0.53318036",
"0.5318617",
"0.52430534",
"0.52396625",
"0.5229975",
"0.5221... | 0.655959 | 0 |
Returns the CRS (Coordinate Reference System) of the raster | def get_raster_crs(raster_path):
raster = rasterio.open(raster_path)
return raster.crs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crs(self):\n return self._crs",
"def _get_raw_crs(self) -> riocrs.CRS:\n # Open metadata\n root, _ = self.read_mtd()\n\n # Get CRS\n crs_name = root.findtext(\".//MapProjection\")\n\n if not crs_name:\n crs_name = vectors.WGS84\n\n return riocrs.CRS... | [
"0.7451072",
"0.7410187",
"0.7228984",
"0.71266246",
"0.6917967",
"0.66791284",
"0.6674292",
"0.6614727",
"0.65814567",
"0.64536196",
"0.6270467",
"0.6167712",
"0.6128253",
"0.5984987",
"0.59417385",
"0.58857507",
"0.58390284",
"0.582477",
"0.581725",
"0.57973796",
"0.5796361... | 0.7941894 | 0 |
Get the position of the missed_value in all square neighbors | def position_surroundings(self, neighbour_pos, missed_value):
pos = []
for x, y in neighbour_pos:
position = self._square_matrix[x][y].get_pos_from_number(missed_value)
if position:
pos.append(position)
return pos | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_unsettled_spot(self):\n\t\tfor i in range(9):\n\t\t\tfor j in range(9):\n\t\t\t\tif self.grid[i][j] == 0:\n\t\t\t\t\treturn i, j\n\t\treturn",
"def _get_neighbours(self, position):\n grid = self._grid\n x, y = position\n neighbours = []\n offsets = [(0,1),(1,0),(0,-1),(-1,0)]... | [
"0.7205239",
"0.6487098",
"0.62197286",
"0.621028",
"0.6183383",
"0.6171833",
"0.6132711",
"0.60654384",
"0.6031553",
"0.60310304",
"0.60268855",
"0.60259557",
"0.5989147",
"0.59822845",
"0.5950342",
"0.5935506",
"0.5918549",
"0.5903765",
"0.5888374",
"0.58830476",
"0.5880375... | 0.74833155 | 0 |
Zero out (but remember) the weight on this node | def clear(self):
self.weight = 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zero_weight():\n return Weight(kg=0)",
"def reset_weights(self):\n self.head.reset_weights()",
"def clear(self):\n for i in range(0, len(self.weights)):\n self.weights[i] = 0",
"def initializeWeightsToZero(self):\n\t\t## YOUR CODE BELOW\n\t\t\n\t\tutil.raiseNotDefined()\n\t\tr... | [
"0.77741355",
"0.73818123",
"0.7308508",
"0.71057844",
"0.706317",
"0.705924",
"0.6891523",
"0.68373996",
"0.67115164",
"0.66507685",
"0.66476434",
"0.6619531",
"0.6595727",
"0.64887065",
"0.64618355",
"0.64608634",
"0.6412731",
"0.6372227",
"0.63027966",
"0.6295642",
"0.6287... | 0.8046396 | 0 |
Dijkstra's algorithm to compute the shortest distance to all vertices vs from a given source vertex s by traveling the edges e | def dijkstra(vs, es, s, stop = None):
initialize_single_source(vs, es, s)
key = lambda x: -1 * x._ss_d
Q = pq(vs)
edict = defaultdict(set)
for e in es:
edict[e.v1].add(e)
edict[e.v2].add(e)
for i in range(len(vs)):
# min path to u is determined at end of loop
u =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_path(vs, es, source, target):\n dijkstra(vs, es, source, stop = target)\n test = target\n result = []\n while test != source:\n e = test._ss_edge\n result.append(e)\n test = e.v1 if e.v1 != test else e.v2\n assert test == source and test._ss_edge is None\n return resu... | [
"0.737509",
"0.7104303",
"0.70790184",
"0.7037781",
"0.70306695",
"0.70016694",
"0.6955521",
"0.69549",
"0.6942236",
"0.693058",
"0.6905992",
"0.6871426",
"0.68237275",
"0.67962337",
"0.6783549",
"0.67635256",
"0.67245734",
"0.67188764",
"0.6700067",
"0.6671806",
"0.6660965",... | 0.73207426 | 1 |
Return min path from source to target, on the graph described the vertices vs and edges es | def min_path(vs, es, source, target):
dijkstra(vs, es, source, stop = target)
test = target
result = []
while test != source:
e = test._ss_edge
result.append(e)
test = e.v1 if e.v1 != test else e.v2
assert test == source and test._ss_edge is None
return result[::-1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shortestPath(self, source, target):\n dist = {}\n prev = {}\n q = []\n for y,a in enumerate(self.sm):\n for x,b in enumerate(self.sm[y]):\n dist[(x,y)] = sys.maxint\n prev[(x,y)] = None\n q.append((x,y))\n dist[sourc... | [
"0.7420686",
"0.73137337",
"0.7145276",
"0.7083855",
"0.6987937",
"0.68091285",
"0.68024665",
"0.6783143",
"0.67707956",
"0.67509186",
"0.66613495",
"0.66289914",
"0.65742147",
"0.6509377",
"0.6435959",
"0.64237475",
"0.64171004",
"0.6385649",
"0.6310933",
"0.62928414",
"0.62... | 0.8422774 | 0 |
Require that user is a designated study admin or site admin. | def _requireStudyAdmin(self, user):
studyAdminsGroup = self.model('group').findOne({'name': 'Study Administrators'})
if not studyAdminsGroup or studyAdminsGroup['_id'] not in user['groups']:
if not user.get('admin', False):
raise AccessException(
'Only mem... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_admin():\n\tif not current_user.is_admin:\n\t\tabort(403)",
"def check_admin():\r\n if not current_user.is_admin:\r\n abort(403)",
"def validate_admin(self, request):\n\n self.validate_login(request)\n\n if request.session['id'] not in self.admins:\n handler.logHelp... | [
"0.69412476",
"0.68771887",
"0.6837426",
"0.6823092",
"0.6823092",
"0.6561765",
"0.6527417",
"0.65214103",
"0.6505473",
"0.649122",
"0.6457141",
"0.64561474",
"0.6453968",
"0.64320403",
"0.6393753",
"0.63883823",
"0.6383777",
"0.63770217",
"0.6367018",
"0.6363484",
"0.6358560... | 0.8191438 | 0 |
Method to retrieve the current values of the RAMSTKSurvivalData data model attributes. | def get_attributes(self):
_attributes = (self.survival_id, self.record_id, self.name,
self.source_id, self.failure_date, self.left_interval,
self.right_interval, self.status_id, self.quantity,
self.tbf, self.mode_type_id, self.nevada_chart,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_attributes(self, attributes):\n\n _error_code = 0\n _msg = \"RAMSTK SUCCESS: Updating RAMSTKSurvivalData {0:d} attributes.\". \\\n format(self.record_id)\n\n try:\n self.name = str(none_to_default(attributes[0], ''))\n self.source_id = int(none_to_de... | [
"0.6175949",
"0.57532144",
"0.5705181",
"0.5604731",
"0.5507315",
"0.55062205",
"0.5477761",
"0.5460437",
"0.54542017",
"0.5453412",
"0.54475814",
"0.54407895",
"0.543573",
"0.54245627",
"0.5412884",
"0.54101944",
"0.5404969",
"0.53737324",
"0.5372602",
"0.53625053",
"0.53558... | 0.60048467 | 1 |
Method to set the RAMSTKSurvivalData data model attributes. | def set_attributes(self, attributes):
_error_code = 0
_msg = "RAMSTK SUCCESS: Updating RAMSTKSurvivalData {0:d} attributes.". \
format(self.record_id)
try:
self.name = str(none_to_default(attributes[0], ''))
self.source_id = int(none_to_default(attributes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_data(self, df):\r\n # Check data is correct.\r\n cols = df.shape[1]\r\n conditions = [cols > 2,\r\n df.index.name == 'r',\r\n df.columns[0] == 't']\r\n if False in conditions:\r\n raise ValueError(f'{self} wrong data set.')\r\... | [
"0.5710973",
"0.55717885",
"0.549497",
"0.54572797",
"0.54424727",
"0.53505176",
"0.5346848",
"0.5270459",
"0.525862",
"0.52214503",
"0.52036566",
"0.51715165",
"0.5162624",
"0.5158768",
"0.5143201",
"0.5112687",
"0.51016325",
"0.5100083",
"0.50965685",
"0.5088955",
"0.506217... | 0.68005687 | 0 |
Load dataset from files in a given folder. This function looks for files train_x.npy, train_y.npy, val_x.npy, val_y.npy, test_x.npy and test_y.npy Returns a DataSet instance | def load_from_path(name, folder):
tx_file = "{0:s}/train_x.npy".format(folder)
if not os.path.isfile(tx_file):
raise DataSetException("Training file not found.")
ty_file = "{0:s}/train_y.npy".format(folder)
if not os.path.isfile(ty_file):
ty_file = None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_dataset(self):\n # Get all the files in the directory\n file_list = self.get_file_list()\n\n # Concatenate the data corresponding to a list of files\n data = self.concatenate_file_data(file_list)\n\n # Shuffle the data and create the training and the validation datasets\... | [
"0.73315185",
"0.7232152",
"0.71712154",
"0.7141634",
"0.71336424",
"0.70842564",
"0.70469034",
"0.6936982",
"0.69206196",
"0.6883277",
"0.68169415",
"0.680937",
"0.6802778",
"0.6749382",
"0.67437637",
"0.66981876",
"0.6645925",
"0.6645303",
"0.6644778",
"0.6613466",
"0.65884... | 0.7468724 | 0 |
Read vapor pressure parameters file and fill in parameters that are needed for vapor pressure curve | def readVP(self,species):
f = open('VPparams.txt', 'rU')
lines = f.readlines()
f.close()
parsing = False
for i in np.arange(len(lines)):
if lines[i].startswith(species):
parsing = True
else:
parsing = False
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pressure(self, values):\n self._part = float(values.get('art', self._part))\n self._pven = float(values.get('ven', self._pven))",
"def pressure(self, values):\n self._part = float(values.get('art', self._part))\n self._pven = float(values.get('ven', self._pven))",
"def pressure(... | [
"0.6387034",
"0.6387034",
"0.6387034",
"0.6251736",
"0.61700636",
"0.61116606",
"0.58959746",
"0.5895648",
"0.58670104",
"0.5846452",
"0.58459103",
"0.57842356",
"0.5780423",
"0.5775546",
"0.57528794",
"0.5751866",
"0.5723168",
"0.5717525",
"0.56907386",
"0.56444967",
"0.5605... | 0.6842268 | 0 |
Subclasses should implement this method in order to take action when a task is scanned There is no diff passed, because this method is called when there is no information about the previous state of a task. | def task_scanned(now_task): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def task_changed(old_task, diff, now_task):",
"def task_scanned_template(task_id):\n #now_task = self._task_api_service.get_current_task_state(task_id)\n task = _client.tasks.find_by_id(task_id)\n altered_task = self.task_scanned(task)\n\n #diff = self._task_diff_service.calculate_dif... | [
"0.6763695",
"0.6342406",
"0.6217184",
"0.6168291",
"0.61488265",
"0.61090827",
"0.60786176",
"0.60786176",
"0.59393173",
"0.59091526",
"0.5881955",
"0.58488715",
"0.58312756",
"0.5780966",
"0.57751566",
"0.57066983",
"0.57066983",
"0.56682956",
"0.5654614",
"0.5641109",
"0.5... | 0.78586817 | 0 |
Template method strategy for creating action for taskChanged we have old and now states, and can pass this to a handler. | def task_changed_template(task_id):
#Assume for now that we can definitely get the event from an event stream
old_task = self._storage_service.get_stored_task(task_id)
now_task = self._task_api_service.get_current_task_state(task_id)
diff = self._task_diff_service.calculate_diff_for_task... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def task_changed(old_task, diff, now_task):",
"def task_changed(self, fields):\n update = {}\n for field in fields:\n update[field] = self.__data[field]\n\n self.connection.update_task(self.name, update)",
"def update_job_state(self, *tasks, **extra_args):\n pass",
"def... | [
"0.76264495",
"0.62410367",
"0.62073314",
"0.6146876",
"0.60325545",
"0.5998154",
"0.59310573",
"0.59260416",
"0.5913432",
"0.59117657",
"0.5901368",
"0.5867086",
"0.5856196",
"0.5856196",
"0.58469135",
"0.58452576",
"0.58048415",
"0.5733319",
"0.5696745",
"0.56281507",
"0.56... | 0.628052 | 1 |
Subclasses should implement this method in order to take action when a task changes It should be assumed that the difference between the old and the new task is represented accurately, but that there may have been intermediate changes in the meantime. For instance, if the task had State A and then becomes State B, and ... | def task_changed(old_task, diff, now_task): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timestamper(task, old_state, new_state):\n new_state.timestamp = pendulum.now(\"utc\")\n if hasattr(old_state, \"timestamp\"):\n duration = (new_state.timestamp - old_state.timestamp).in_seconds()\n task.logger.info(\n \"{} seconds passed in between state transitions\".format(dur... | [
"0.6563116",
"0.6327758",
"0.6302768",
"0.62952566",
"0.6154934",
"0.58865243",
"0.5851994",
"0.5839404",
"0.5794097",
"0.57631093",
"0.57603806",
"0.5752358",
"0.57121783",
"0.5634282",
"0.5623804",
"0.5582487",
"0.5582487",
"0.55473316",
"0.55443513",
"0.55149525",
"0.54999... | 0.80793357 | 0 |
The task may be stagnant. What stagnant means depends on the business logic. One example may be that you expect that the task needs to have, say, a comment placed on it every week; and if that's the requirement, you should check the task that we think might be stagnant in order to verify. | def is_task_stagnant(task): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def task_stagnant(task):",
"def task_stagnant_template(task_id):\n # The intent of this is not to incur *any* restrictions on external sources (like cron) because\n # that goes against the simplicity clause. This is simply checked by this framework every time\n # major events get executed (l... | [
"0.7626539",
"0.66782004",
"0.64053106",
"0.63221794",
"0.6262628",
"0.62052846",
"0.62052846",
"0.61971396",
"0.6168194",
"0.6131822",
"0.61091554",
"0.60977364",
"0.60569406",
"0.5902786",
"0.5871476",
"0.58550227",
"0.58522946",
"0.5828267",
"0.5806666",
"0.57601726",
"0.5... | 0.83593345 | 0 |
get all the children on gmac_id from redis DB, much FASTER | def get_all_children_from_redis(gmac_id, as_objects=True):
conn = get_redis_connection()
klass = GoogleMapsAddressComponent
results = klass.get_all_children_id_list_from_redis_by_pk(gmac_id)
if as_objects:
results = klass.objects.filter(pk__in=results)
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_children_id_list_from_redis_by_pk(gmac_id):\n try:\n gmac = GoogleMapsAddressComponent.objects.get(pk=gmac_id)\n conn = get_redis_connection()\n key = GoogleMapsAddressComponent.get_redis_all_children_key(gmac_id)\n length = conn.llen(key)\n ... | [
"0.8152746",
"0.79024535",
"0.6686107",
"0.65141815",
"0.641508",
"0.639633",
"0.6068185",
"0.60418916",
"0.6006778",
"0.5979434",
"0.597477",
"0.5762077",
"0.57298154",
"0.5690725",
"0.56153274",
"0.5591066",
"0.55792207",
"0.55651486",
"0.5542288",
"0.5512591",
"0.55021805"... | 0.7953534 | 1 |
synchronizes all the children to a Redis list | def sync_all_children_to_redis(self):
conn = get_redis_connection()
key = GoogleMapsAddressComponent.get_redis_all_children_key(self.pk)
# First, we make sure the key gets destroyed if it exists
conn.delete(key)
# Now we add the keys of the children to the list
children =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sync_children(self, source_parent, destination_parent, new_child):\n destination_reordered = []\n destination_children = set(destination_parent.fields['children'])\n source_children = source_parent.fields['children']\n orphans = destination_children - set(source_children)\n ... | [
"0.5846084",
"0.5746459",
"0.5725607",
"0.56974477",
"0.5600698",
"0.55633664",
"0.55478585",
"0.5531039",
"0.5527182",
"0.5519314",
"0.5518972",
"0.55158573",
"0.5498162",
"0.5470758",
"0.5470408",
"0.54163337",
"0.54001063",
"0.53624684",
"0.53552",
"0.53313947",
"0.52982",... | 0.85803103 | 0 |
Generator function that outputs the paper title, index, and citations for each entry | def __citationsFromFile(file):
# Tokens for parsing
titleToken = '#*'
indexToken = '#index'
citationToken = '#%'
# Predicates for error checking
noneNone = lambda *items: all([item is not None for item in items])
allNone = lambda *items: all([item is None for item in items])
# Next en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cite_report(self):\n\n num_cites = np.sum(np.array([q.citation_count for q in self.mypapers]))\n print(\"number of citations = \", num_cites)\n\n for n, p in enumerate(self.mypapers):\n clean_tags = re.compile(\"<.*?>\")\n title = re.sub(clean_tags, \"\", p.title[0])\... | [
"0.6398447",
"0.6009631",
"0.59154475",
"0.5905178",
"0.58975077",
"0.5821678",
"0.5820468",
"0.5633226",
"0.56244",
"0.56077796",
"0.5602855",
"0.55395496",
"0.55325943",
"0.5529402",
"0.5523234",
"0.5480759",
"0.54773694",
"0.5460018",
"0.5447724",
"0.5437615",
"0.5431244",... | 0.6384073 | 1 |
Read GFF3formatted data in the specified file (or filelike object) Return a pandas dataframe with ID, Parent, seqid, source, type, start, end, score, strand, phase, and attributes columns. The ID and Parent are extracted from the attributes columns, and the dataframe is indexed by ID | def gff3_to_dataframe( file ):
result = _read_gff3_using_pandas( file )
extract_attributes_to_columns( result, ['ID', 'Parent', 'Name' ] )
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_gff3_using_pandas( file ):\n import pandas\n result = pandas.read_table(\n file,\n comment = '#',\n names = [ 'seqid', 'source', 'type', 'start', 'end', 'score', 'strand', 'phase', 'attributes' ],\n na_values = \".\",\n dtype = {\n 'seqid': str,\n ... | [
"0.7699503",
"0.65951246",
"0.6426204",
"0.62687147",
"0.6233554",
"0.6230566",
"0.61066884",
"0.6091305",
"0.60736585",
"0.59793144",
"0.5864509",
"0.58356196",
"0.58144176",
"0.5696015",
"0.566202",
"0.56447494",
"0.5621449",
"0.5619404",
"0.557519",
"0.5569083",
"0.5558418... | 0.81290424 | 0 |
Helper function to read the given GFF3 file into a dataframe, without any postprocessing. | def _read_gff3_using_pandas( file ):
import pandas
result = pandas.read_table(
file,
comment = '#',
names = [ 'seqid', 'source', 'type', 'start', 'end', 'score', 'strand', 'phase', 'attributes' ],
na_values = ".",
dtype = {
'seqid': str,
'source': ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gff3_to_dataframe( file ):\n result = _read_gff3_using_pandas( file )\n extract_attributes_to_columns( result, ['ID', 'Parent', 'Name' ] )\n return result",
"def read_in_gtf(infile_path, gtf_rows_to_skip): \n\tdf = pd.read_csv(infile_path, compression='gzip', sep='\\t', dtype=str, header=None, skipr... | [
"0.7671827",
"0.68784577",
"0.68401384",
"0.6406066",
"0.63211954",
"0.60683244",
"0.5996769",
"0.5982758",
"0.5978171",
"0.59537876",
"0.5921268",
"0.5912143",
"0.5900824",
"0.59005004",
"0.58473027",
"0.5828351",
"0.5819334",
"0.5815665",
"0.57983077",
"0.5795755",
"0.57552... | 0.7767748 | 0 |
GFF3 files from the Ensembl ftp site list sequences and their lengths in the file metadata. This function parses this information and returns it as a pandas dataframe. It's use may be specific to the Ensembl files. | def parse_sequences_from_gff_metadata( file ):
import pandas
result = []
for line in file:
if line.startswith( '##sequence-region' ):
parts = line.strip().split( " " )
nameStartEnd = parts[-3:] # last 3 elements
result.append({
"seqid": nameStartEn... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_gff3_using_pandas( file ):\n import pandas\n result = pandas.read_table(\n file,\n comment = '#',\n names = [ 'seqid', 'source', 'type', 'start', 'end', 'score', 'strand', 'phase', 'attributes' ],\n na_values = \".\",\n dtype = {\n 'seqid': str,\n ... | [
"0.5787096",
"0.5700914",
"0.5652596",
"0.55933994",
"0.55396926",
"0.5514567",
"0.546654",
"0.5403991",
"0.53897697",
"0.5375177",
"0.534354",
"0.5343404",
"0.5285535",
"0.52755135",
"0.52441376",
"0.52279055",
"0.5219072",
"0.5205338",
"0.52000976",
"0.51452714",
"0.5143794... | 0.6558859 | 0 |
use the multiprocessing to speed up trees construction | def construct_trees_with_mp(self, nodes):
cores = multiprocessing.cpu_count() // 2
pool = multiprocessing.Pool(cores)
new_nodes = []
n_node_per_core = self.n_node // cores
for i in range(cores):
if i != cores - 1:
new_nodes.append(nodes[i * n_node_per... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __build_iteration(self) -> None:\n trees = [t for t in self.__trees.keys()]\n for tree in trees:\n heads = []\n branches = self.__trees[tree]\n for i in range(len(branches) - 1, -1, -1):\n if self.__trees.get(tree) and np.random.rand(1)[0] < self.__... | [
"0.6634557",
"0.65097874",
"0.6468073",
"0.6322716",
"0.61754715",
"0.61633855",
"0.6134023",
"0.6103396",
"0.6072749",
"0.6025818",
"0.5942558",
"0.5940306",
"0.59400433",
"0.59197605",
"0.5803043",
"0.5800409",
"0.5730466",
"0.57235837",
"0.570595",
"0.56996745",
"0.5682015... | 0.67621195 | 0 |
given a path from root to a sampled node, generate all the node pairs within the given windows size e.g., path = [1, 0, 2, 4, 2], window_size = 2 > node pairs= [[1, 0], [1, 2], [0, 1], [0, 2], [0, 4], [2, 1], [2, 0], [2, 4], [4, 0], [4, 2]] | def get_node_pairs_from_path(path):
path = path[:-1]
pairs = []
for i in range(len(path)):
center_node = path[i]
for j in range(max(i - config.window_size, 0), min(i + config.window_size + 1, len(path))):
if i == j:
continue
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_data_for_g(self):\n\n paths = []\n for i in self.root_nodes:\n if np.random.rand() < config.update_ratio:\n sample, paths_from_i = self.sample(i, self.trees[i], config.n_sample_gen, for_d=False)\n if paths_from_i is not None:\n p... | [
"0.6034385",
"0.58849245",
"0.5821947",
"0.57078713",
"0.567708",
"0.5635777",
"0.55671024",
"0.5543528",
"0.5502547",
"0.5464833",
"0.54600173",
"0.54036397",
"0.53936696",
"0.5389518",
"0.538797",
"0.5360911",
"0.5360335",
"0.5356528",
"0.5354449",
"0.5350147",
"0.5309977",... | 0.66977215 | 0 |
write embeddings of the generator and the discriminator to files | def write_embeddings_to_file(self):
modes = [self.generator, self.discriminator]
for i in range(2):
embedding_matrix = modes[i].embedding_matrix
embedding_matrix = embedding_matrix.detach().to('cpu').numpy()
index = np.array(range(self.n_node)).reshape(-1, 1)
embeddin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export_embeddings(self):\n save_path = self.config.path_embeddings / self.model.model_name\n save_path.mkdir(parents=True, exist_ok=True)\n \n idx2ent = self.model.config.knowledge_graph.read_cache_data('idx2entity')\n idx2rel = self.model.config.knowledge_graph.read_cache_da... | [
"0.6645376",
"0.616794",
"0.6127513",
"0.6118077",
"0.6082668",
"0.6051448",
"0.60008365",
"0.5980834",
"0.59451413",
"0.5944806",
"0.5940215",
"0.5940215",
"0.5868026",
"0.58156615",
"0.5809229",
"0.58066696",
"0.58032924",
"0.58025366",
"0.5781701",
"0.57721895",
"0.5767009... | 0.8185345 | 0 |
Emit an Operation at the current position. Sets result register if not set already. | def emit(self, op):
assert self._curblock, "Builder is not positioned!"
if op.result is None:
op.result = self.func.temp()
if self._lastop == 'head' and self._curblock.ops.head:
op.insert_before(self._curblock.ops.head)
elif self._lastop in ('head', 'tail'):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def emit(self, instruction):\n return self.builder.emit(instruction)",
"def output_op(self, op):\n self.output['text'] += ' ' + op + ' ' \n self.seen_op = True",
"def next_operation(self):\n raise NotImplementedError",
"def add_operation(self):\n arg1 = self.memory[self.me... | [
"0.642982",
"0.62555254",
"0.6210357",
"0.6160179",
"0.60740376",
"0.5878905",
"0.5864841",
"0.58310556",
"0.5782979",
"0.5778094",
"0.57313156",
"0.57203454",
"0.5717315",
"0.5639052",
"0.56168175",
"0.5579971",
"0.54953563",
"0.54846054",
"0.54685915",
"0.54667056",
"0.5422... | 0.7211463 | 0 |
Position the builder at the beginning of the given block. | def position_at_beginning(self, block):
self._curblock = block
self._lastop = 'head' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position_before(self, op):\n if isinstance(op, FuncArg):\n raise error.PositioningError(\n \"Cannot place builder before function argument\")\n self._curblock = op.block\n self._lastop = op._prev",
"def begin():\n return BeginBlock()",
"def createFirstBlock... | [
"0.6780588",
"0.657286",
"0.65366715",
"0.6378802",
"0.6168305",
"0.59907305",
"0.5931497",
"0.5873343",
"0.5858289",
"0.5858289",
"0.5829275",
"0.5818509",
"0.5761768",
"0.5753733",
"0.57440203",
"0.5732442",
"0.57301",
"0.5676104",
"0.5670693",
"0.56525517",
"0.5638855",
... | 0.80572224 | 0 |
Position the builder at the end of the given block. | def position_at_end(self, block):
self._curblock = block
self._lastop = block.tail or 'tail' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position_after(self, op):\n if isinstance(op, FuncArg):\n self.position_at_beginning(op.parent.startblock)\n else:\n self._curblock = op.block\n self._lastop = op",
"def end():\n return EndBlock()",
"def RespEnd(builder):\n return End(builder)",
"def G... | [
"0.68136996",
"0.67185444",
"0.6190995",
"0.61247826",
"0.60937697",
"0.6060488",
"0.60131776",
"0.59254843",
"0.5914432",
"0.59005034",
"0.58558226",
"0.5840668",
"0.5792603",
"0.5767451",
"0.5759115",
"0.57441527",
"0.5667821",
"0.5667821",
"0.5660413",
"0.5648996",
"0.5636... | 0.75534904 | 0 |
Position the builder before the given op. | def position_before(self, op):
if isinstance(op, FuncArg):
raise error.PositioningError(
"Cannot place builder before function argument")
self._curblock = op.block
self._lastop = op._prev | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position_after(self, op):\n if isinstance(op, FuncArg):\n self.position_at_beginning(op.parent.startblock)\n else:\n self._curblock = op.block\n self._lastop = op",
"def emit(self, op):\n assert self._curblock, \"Builder is not positioned!\"\n\n if... | [
"0.6777482",
"0.6292546",
"0.6218918",
"0.6052035",
"0.59945905",
"0.5801662",
"0.56987685",
"0.5685576",
"0.5647879",
"0.54777586",
"0.53614604",
"0.53515476",
"0.5339638",
"0.53279823",
"0.5269136",
"0.5266044",
"0.5263959",
"0.5225988",
"0.5225988",
"0.52121824",
"0.520948... | 0.87499154 | 0 |
Position the builder after the given op. | def position_after(self, op):
if isinstance(op, FuncArg):
self.position_at_beginning(op.parent.startblock)
else:
self._curblock = op.block
self._lastop = op | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position_before(self, op):\n if isinstance(op, FuncArg):\n raise error.PositioningError(\n \"Cannot place builder before function argument\")\n self._curblock = op.block\n self._lastop = op._prev",
"def emit(self, op):\n assert self._curblock, \"Builder i... | [
"0.718077",
"0.6929871",
"0.5845374",
"0.57306945",
"0.56287616",
"0.54109967",
"0.53804183",
"0.5341464",
"0.5304844",
"0.52726626",
"0.5257731",
"0.5215819",
"0.5215819",
"0.517075",
"0.5169561",
"0.51237255",
"0.51043963",
"0.5063665",
"0.50462085",
"0.5042502",
"0.5014034... | 0.8053975 | 0 |
Propagate an exception. If `exc` is not given it will be loaded to match in 'except' clauses. | def gen_error_propagation(self, exc=None):
assert self._curblock
block = self._curblock
exc_setup = findop(block.leaders, 'exc_setup')
if exc_setup:
exc = exc or self.load_tl_exc(types.Exception)
self._find_handler(exc, exc_setup)
else:
self.g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _propagate_exc(self):\n catch_op = self._find_handler()\n if catch_op:\n # Exception caught! Transfer control to block\n catch_block = catch_op.parent\n self.pc = self.blockstarts[catch_block.name]\n else:\n # No exception handler!\n r... | [
"0.6327253",
"0.602761",
"0.5974743",
"0.5897044",
"0.5897044",
"0.58730125",
"0.5812579",
"0.5781652",
"0.5733888",
"0.5635754",
"0.56160176",
"0.5546794",
"0.5500533",
"0.54902285",
"0.54452264",
"0.54216564",
"0.5380202",
"0.53723145",
"0.5351295",
"0.5333911",
"0.5310856"... | 0.65648335 | 0 |
Generate a return with undefined value | def gen_ret_undef(self):
type = self.func.type.restype
if type.is_void:
self.ret(None)
else:
self.ret(Undef(type)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def return_none() -> None:\n pass",
"def get_nothing():\n return \"\" # intentional non-existent variable",
"def null() -> SetupVal:\n return NullVal()",
"def get_none1(self):\n pass",
"def function_with_wrong_return() -> None:\n return 42",
"def get_return_value(self):\n return... | [
"0.71695924",
"0.702917",
"0.63986486",
"0.62983674",
"0.6256622",
"0.6242176",
"0.62280655",
"0.6171779",
"0.6141852",
"0.61372393",
"0.61182797",
"0.6094714",
"0.6093091",
"0.60747826",
"0.6060189",
"0.6041134",
"0.603262",
"0.59996945",
"0.5962412",
"0.5952938",
"0.5946937... | 0.75520056 | 0 |
Split the current block, returning (old_block, new_block) | def splitblock(self, name=None, terminate=False):
# -------------------------------------------------
# Sanity check
# Allow splitting only after leaders and before terminator
# TODO: error check
# -------------------------------------------------
# Split
oldbl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split(self, block: ghidra.program.model.mem.MemoryBlock, addr: ghidra.program.model.address.Address) -> None:\n ...",
"def changed_block(self, old_block, new_block):",
"def test_block_split(self):\n block1 = self.geographies.find({ 'geoid': '150010210051016' }) \n self.assertEqual(bloc... | [
"0.7007891",
"0.6474244",
"0.63708407",
"0.6220532",
"0.5873715",
"0.5784748",
"0.57539546",
"0.5708441",
"0.5696605",
"0.5676573",
"0.56721663",
"0.56536955",
"0.55770147",
"0.5571765",
"0.55206585",
"0.5516312",
"0.5514029",
"0.55035573",
"0.54716635",
"0.5471263",
"0.54684... | 0.72078073 | 0 |
Patch uses of the instructions in `ops` when a predecessor changes from `oldblock` to `newblock` | def _patch_phis(self, ops, oldblock, newblock):
for op in ops:
for use in self.func.uses[op]:
if use.opcode == 'phi':
# Update predecessor blocks
preds, vals = use.args
preds = [newblock if pred == oldblock else pred
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def changed_block(self, old_block, new_block):",
"def _poputil_block_recompute_backward(op, grads):\n return grads",
"def replaceChain(self, newbc):\n if (Blockchain.validChain(newbc) == False):\n print(\"New Blockchain is invalid\")\n return\n elif (len(newbc.chain) < len(... | [
"0.7141038",
"0.5633429",
"0.5507244",
"0.546693",
"0.5414261",
"0.5385301",
"0.5373628",
"0.5321918",
"0.53146756",
"0.5311769",
"0.53000045",
"0.5256756",
"0.52212864",
"0.52187675",
"0.5158157",
"0.51488775",
"0.51406777",
"0.5132721",
"0.51189345",
"0.50957066",
"0.509176... | 0.76315385 | 0 |
Generate a loop given start, stop, step and the index variable type. The builder's position is set to the end of the body block. Returns (condition_block, body_block, exit_block). | def gen_loop(self, start=None, stop=None, step=None):
assert isinstance(stop, Value), "Stop should be a Constant or Operation"
ty = stop.type
start = start or Const(0, ty)
step = step or Const(1, ty)
assert start.type == ty == step.type
with self.at_front(self.func.sta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_for(self, stmt: statements.For) -> None:\n condition_block = self.builder.new_block()\n body_block = self.builder.new_block()\n final_block = self.builder.new_block()\n iterator_block = self.builder.new_block()\n self.break_block_stack.append(final_block)\n self.co... | [
"0.5881916",
"0.5810891",
"0.5258655",
"0.52414805",
"0.50282264",
"0.49179763",
"0.48754445",
"0.48476613",
"0.47897246",
"0.47825179",
"0.47693425",
"0.47301555",
"0.4664564",
"0.46524873",
"0.464208",
"0.46326712",
"0.46270207",
"0.4616576",
"0.4600605",
"0.458489",
"0.457... | 0.73493594 | 0 |
Adds a weight variable to the layer. | def add_weight(self,
name,
shape,
dtype=None,
initializer=None,
regularizer=None,
trainable=True,
constraint=None):
if dtype is None:
dtype = K.floatx()
weight = self.add_variable(name, s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_weight(self, weight, layer_name, tag):\n if tag != 'bias' and tag != 'wmat':\n raise Exception('tag must be bias or wmat')\n cxnlib.CXNNetSetWeight(self.handle,\n weight.ctypes.data_as(ctypes.POINTER(ctypes.c_float)),\n we... | [
"0.65926033",
"0.6463909",
"0.64615434",
"0.64615434",
"0.64615434",
"0.6434855",
"0.64340943",
"0.6415618",
"0.64081067",
"0.64048344",
"0.63897765",
"0.6330229",
"0.63140184",
"0.63023055",
"0.629226",
"0.6286121",
"0.6258184",
"0.62510973",
"0.6248951",
"0.6238682",
"0.623... | 0.75557965 | 0 |
Retrieves the input mask tensor(s) of a layer at a given node. | def get_input_mask_at(self, node_index):
inputs = self.get_input_at(node_index)
if isinstance(inputs, list):
return [getattr(x, '_keras_mask', None) for x in inputs]
else:
return getattr(inputs, '_keras_mask', None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_input_masks(nx_node, nx_graph):\n input_edges = list(nx_graph.in_edges(nx_node['key']))\n input_masks = [nx_graph.nodes[input_node]['output_mask'] for input_node, _ in input_edges]\n return input_masks",
"def get_input_masks(nx_node, nx_graph):\n input_edges = list(nx_graph.in_edges(nx_node[\... | [
"0.7356327",
"0.7356168",
"0.70601845",
"0.686372",
"0.6512168",
"0.6421162",
"0.6359002",
"0.6270404",
"0.61987",
"0.6198212",
"0.6178",
"0.6079104",
"0.60541415",
"0.6017263",
"0.5996643",
"0.5978338",
"0.5978338",
"0.59334666",
"0.59316564",
"0.5927264",
"0.5876722",
"0.... | 0.78300685 | 0 |
Retrieves the output mask tensor(s) of a layer at a given node. | def get_output_mask_at(self, node_index):
output = self.get_output_at(node_index)
if isinstance(output, list):
return [getattr(x, '_keras_mask', None) for x in output]
else:
return getattr(output, '_keras_mask', None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output_mask(self):\n output = self.output\n if isinstance(output, list):\n return [getattr(x, '_keras_mask', None) for x in output]\n else:\n return getattr(output, '_keras_mask', None)",
"def get_input_mask_at(self, node_index):\n inputs = self.get_input_at(node_index)\n if isinstan... | [
"0.70013404",
"0.67517936",
"0.6399421",
"0.6388399",
"0.6365272",
"0.62206274",
"0.5890313",
"0.58897936",
"0.58688754",
"0.584128",
"0.58091635",
"0.578257",
"0.57217216",
"0.56831867",
"0.5655766",
"0.5625976",
"0.56219614",
"0.5602559",
"0.5580995",
"0.5553757",
"0.552901... | 0.80216116 | 0 |
Retrieves the input mask tensor(s) of a layer. Only applicable if the layer has exactly one inbound node, i.e. if it is connected to one incoming layer. | def input_mask(self):
inputs = self.input
if isinstance(inputs, list):
return [getattr(x, '_keras_mask', None) for x in inputs]
else:
return getattr(inputs, '_keras_mask', None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_input_mask_at(self, node_index):\n inputs = self.get_input_at(node_index)\n if isinstance(inputs, list):\n return [getattr(x, '_keras_mask', None) for x in inputs]\n else:\n return getattr(inputs, '_keras_mask', None)",
"def get_input_masks(nx_node, nx_graph):\n input_edges = list(n... | [
"0.756858",
"0.72555685",
"0.7244732",
"0.66529214",
"0.6584047",
"0.6530159",
"0.6530159",
"0.6504658",
"0.64577276",
"0.64186",
"0.6376844",
"0.6373097",
"0.63566697",
"0.6205893",
"0.62017626",
"0.6168873",
"0.6005357",
"0.5990894",
"0.5963304",
"0.5865473",
"0.5858816",
... | 0.7356791 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.