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 |
|---|---|---|---|---|---|---|
Load and validate a config file, returning any errors encountered. If the config file is valid, the tuple returned contains the loaded config as the first element, and the second element is None. Otherwise, the second element is an iterable of errors that occurred during validation | def check_config(
config_file: Path,
) -> Tuple[Optional[Dict[str, Any]], Optional[Iterable[errors.ValidationError]]]:
load_data = parse_config(config_file)
load_data, load_data_dup = tee(load_data)
first = next(load_data_dup)
if isinstance(first, errors.ValidationError):
validation_errors =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_config(\n config_file: Path,\n) -> Iterable[Union[errors.ValidationError, Dict[str, Any]]]:\n # root = config_file.parent\n config = load_any(config_file)\n schema_errors: Iterable[errors.SchemaValidationError] = (\n errors.SchemaValidationError(str(e), e)\n for e in config_sche... | [
"0.73096585",
"0.68011",
"0.6606892",
"0.638414",
"0.6333747",
"0.61956245",
"0.6187002",
"0.60878813",
"0.6080821",
"0.60753626",
"0.60023487",
"0.6002032",
"0.5985557",
"0.5974979",
"0.5974979",
"0.59661037",
"0.5951037",
"0.5942092",
"0.59041005",
"0.59037936",
"0.5863309"... | 0.795852 | 0 |
Loads a config file, or throw an exception if it is not valid | def load_config(config_file: Path) -> Dict[str, Any]:
config, errors = check_config(config_file)
if errors is not None:
raise next(iter(errors))
# errors is None
assert config is not None
return config | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cli_load_config(self, args) -> str:\n path = args.config_path\n if not os.path.isfile(path):\n return error(\"Path {} DNE\".format(path))\n\n try:\n self.config = config.from_file(path)\n return ok(\"Configuration loaded from {}\".format(path))\n exc... | [
"0.7601103",
"0.74409306",
"0.7427742",
"0.73445207",
"0.7344369",
"0.73436534",
"0.7332355",
"0.7284374",
"0.7253979",
"0.72053397",
"0.7204084",
"0.7203225",
"0.71599305",
"0.7146686",
"0.7126887",
"0.7115745",
"0.71139956",
"0.7109619",
"0.7101705",
"0.7047698",
"0.7028954... | 0.76747537 | 0 |
Enter SwitcherBridge asynchronous context manager. | async def __aenter__(self) -> "SwitcherBridge":
await self.start()
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activate():\n refresh()\n activate_connection_with_mainloop(get_uuid())",
"async def __aenter__(self):\n await self.start()",
"async def __aenter__(self) -> 'BaseAgent':\n\n return await self.open()",
"def switch():\n return Awaitable()",
"def stasis_start_cb(channel, ev):\n a... | [
"0.6332844",
"0.6325681",
"0.6321533",
"0.6101696",
"0.57948446",
"0.5786901",
"0.5741127",
"0.5712348",
"0.5669127",
"0.5625606",
"0.5625606",
"0.562332",
"0.55336386",
"0.55336386",
"0.55250365",
"0.5493556",
"0.5477489",
"0.5465742",
"0.54586947",
"0.54450357",
"0.5440988"... | 0.7491586 | 0 |
Extract the IP address from the type1 broadcast message (Heater, Plug). | def get_ip_type1(self) -> str:
hex_ip = hexlify(self.message)[152:160]
ip_addr = int(hex_ip[6:8] + hex_ip[4:6] + hex_ip[2:4] + hex_ip[0:2], 16)
return inet_ntoa(pack("<L", ip_addr)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ip_type2(self) -> str:\n hex_ip = hexlify(self.message)[154:162]\n ip_addr = int(hex_ip[0:2] + hex_ip[2:4] + hex_ip[4:6] + hex_ip[6:8], 16)\n return inet_ntoa(pack(\">L\", ip_addr))",
"def ip_for_event (event):\n eth = dpid_to_str(event.dpid,True).split(\"|\")[0].replace(\"-\",\":\"... | [
"0.62573063",
"0.5983005",
"0.59109694",
"0.5889796",
"0.5855139",
"0.5791712",
"0.5750377",
"0.57353413",
"0.57214594",
"0.5695647",
"0.5687465",
"0.5656045",
"0.56231207",
"0.5519996",
"0.5519413",
"0.5513121",
"0.54990864",
"0.5491366",
"0.5478653",
"0.5467143",
"0.5456707... | 0.70770574 | 0 |
Extract the device id from the broadcast message. | def get_device_id(self) -> str:
return hexlify(self.message)[36:42].decode() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_device_id_from_event(event):\n return event.message.annotations[\"iothub-connection-device-id\".encode()].decode()",
"def device_id(self):\n return self._id[0]",
"def device_id(self) -> str:\n return self._device_info[\"ID\"]",
"def device_id(self):\n return self._annotations.... | [
"0.70864534",
"0.66141975",
"0.6504654",
"0.64821935",
"0.6376667",
"0.6334644",
"0.6326233",
"0.62108934",
"0.6189589",
"0.6149342",
"0.6094864",
"0.6069741",
"0.6030198",
"0.59717447",
"0.5965991",
"0.59284145",
"0.58982235",
"0.5707103",
"0.5660862",
"0.56576896",
"0.56511... | 0.71858644 | 0 |
Extract the device state from the broadcast message. | def get_device_state(self) -> DeviceState:
hex_device_state = hexlify(self.message)[266:268].decode()
return (
DeviceState.ON
if hex_device_state == DeviceState.ON.value
else DeviceState.OFF
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_device_state(self, device_name):\n device_info = self.data.get(device_name)\n return device_info.get('state') if device_info else None",
"def device_state_attributes(self):\n return {\"uuid\": self.uuidAction,\n \"room\": self.room,\n \"category\": self.... | [
"0.59893084",
"0.57019615",
"0.56932735",
"0.56579196",
"0.5648592",
"0.5616866",
"0.555145",
"0.5544498",
"0.5493315",
"0.54372776",
"0.5397859",
"0.53942513",
"0.53653306",
"0.53638494",
"0.536375",
"0.5355793",
"0.5349352",
"0.53458685",
"0.53340346",
"0.5317107",
"0.53083... | 0.65081036 | 0 |
Extract the auto shutdown value from the broadcast message. | def get_auto_shutdown(self) -> str:
hex_auto_shutdown_val = hexlify(self.message)[310:318]
int_auto_shutdown_val_secs = int(
hex_auto_shutdown_val[6:8]
+ hex_auto_shutdown_val[4:6]
+ hex_auto_shutdown_val[2:4]
+ hex_auto_shutdown_val[0:2],
16,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_heartbeat_message(self):\n return self.messages[\"heartbeat\"].get()",
"def shutdown(self):\n return self._read(MX_SHUTDOWN)",
"def pull(self):\n \n data = self.s.recv(1024)\n if data:\n info = json.loads(data.decode()) \n print(\"DATA FROM BROKE... | [
"0.5499507",
"0.5274515",
"0.49070346",
"0.4894385",
"0.48835716",
"0.48745817",
"0.48557547",
"0.48136777",
"0.47831786",
"0.4762295",
"0.4762295",
"0.47481573",
"0.4739972",
"0.47129744",
"0.47009182",
"0.46813038",
"0.46596712",
"0.46524695",
"0.46379837",
"0.462631",
"0.4... | 0.6372114 | 0 |
Extract the power consumption from the broadcast message. | def get_power_consumption(self) -> int:
hex_power_consumption = hexlify(self.message)[270:278]
return int(hex_power_consumption[2:4] + hex_power_consumption[0:2], 16) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_power(self, channel):\n\n power = self.device.query(f':POW{channel}:VAL?')\n return float(power)",
"def get_power_values(self):\n x=self.send_packet_check_response('\\x60')\n return struct.unpack('<iiih',x)",
"def get_power(self):\r\n _debug('simq03b_api.get_power')\r... | [
"0.6030356",
"0.60249543",
"0.5813906",
"0.5777191",
"0.5746",
"0.5744297",
"0.5712377",
"0.57049614",
"0.57049614",
"0.5549503",
"0.5493961",
"0.54691863",
"0.54381156",
"0.53966916",
"0.5382752",
"0.5351965",
"0.53316444",
"0.5309858",
"0.5301612",
"0.52832156",
"0.5234166"... | 0.6581233 | 0 |
Extract the device type from the broadcast message. | def get_device_type(self) -> DeviceType:
hex_model = hexlify(self.message[74:76]).decode()
devices = dict(map(lambda d: (d.hex_rep, d), DeviceType))
return devices[hex_model] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_type(self):\n return Context.devtype2str[self.device_typeid]",
"def device_type(self):\n return Context.devtype2str[self.device_typeid]",
"def device_type(self):\n return self._meta['device_type']",
"def device_type(self):\n # type: () -> string_types\n return se... | [
"0.625213",
"0.625213",
"0.62468296",
"0.61289835",
"0.5936063",
"0.588411",
"0.58595324",
"0.5773678",
"0.57696486",
"0.5759056",
"0.57496417",
"0.57362485",
"0.57100964",
"0.5695006",
"0.5679305",
"0.56452966",
"0.5604981",
"0.5602389",
"0.5600383",
"0.5584659",
"0.5575527"... | 0.6615226 | 0 |
Return the current position of the shutter 0 <= pos <= 100. | def get_shutter_position(self) -> int:
hex_pos = hexlify(self.message[135:137]).decode()
return int(hex_pos[2:4]) + int(hex_pos[0:2], 16) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_position(self, position):",
"def pos(self):\n return (self.raw - self.raw_zero) / self.ratio",
"def get_pos(self):\r\n return self.pos",
"def getTilePos(self, pos = None):\n\n if not pos:\n pos = self.actor.getPos()\n \n for i in range(len(pos)):\n pos[i] = int(math.f... | [
"0.62909096",
"0.61817384",
"0.6158584",
"0.61115795",
"0.60676634",
"0.60562605",
"0.6010754",
"0.5980439",
"0.59123677",
"0.58966935",
"0.5874537",
"0.5850645",
"0.5845945",
"0.58204806",
"0.5793631",
"0.5792949",
"0.573503",
"0.5716095",
"0.56889486",
"0.56889486",
"0.5688... | 0.62485445 | 1 |
Return the current direction of the shutter (UP/DOWN/STOP). | def get_shutter_direction(self) -> ShutterDirection:
hex_direction = hexlify(self.message[137:139]).decode()
directions = dict(map(lambda d: (d.value, d), ShutterDirection))
return directions[hex_direction] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_direction(self):\n return self.wink.current_fan_direction()",
"def get_direction(self) -> int: \r\n if time.time() > self.stop_timer:\r\n return Directions.stop\r\n else:\r\n return self.direction",
"def current_direction(self) -> str:\n if s... | [
"0.7377894",
"0.7003519",
"0.6926874",
"0.6845885",
"0.684002",
"0.6758815",
"0.6755902",
"0.6728268",
"0.66687226",
"0.6613132",
"0.6575908",
"0.65501356",
"0.65354353",
"0.6532375",
"0.65267795",
"0.650473",
"0.6488082",
"0.64337397",
"0.6433097",
"0.64316136",
"0.64236265"... | 0.7295307 | 1 |
Return the current thermostat state. | def get_thermostat_state(self) -> DeviceState:
hex_power = hexlify(self.message[137:138]).decode()
return DeviceState.ON if hex_power == DeviceState.ON.value else DeviceState.OFF | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state(self):\n return self.env.sim.get_state()",
"def get_current_state(self):\n return self._current_state",
"def state(self):\n return self._device.temperature",
"def get_state(self):\n return self.controller.get_state()",
"def get_current_state(self):\n return ... | [
"0.72841996",
"0.71483696",
"0.7144572",
"0.71216285",
"0.7120051",
"0.7117457",
"0.7110498",
"0.7099462",
"0.70663476",
"0.7061033",
"0.7054098",
"0.70529044",
"0.70514995",
"0.7017588",
"0.7017588",
"0.69712144",
"0.6947047",
"0.6907573",
"0.69067836",
"0.6891913",
"0.68785... | 0.74006474 | 0 |
Return the current thermostat mode. | def get_thermostat_mode(self) -> ThermostatMode:
hex_mode = hexlify(self.message[138:139]).decode()
states = dict(map(lambda s: (s.value, s), ThermostatMode))
return ThermostatMode.COOL if hex_mode not in states else states[hex_mode] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mode(self):\r\n return self._api.get_mode()",
"def getmode(self):\n return self.mode",
"def mode(self) -> str:\n return pulumi.get(self, \"mode\")",
"def mode(self) -> str:\n return pulumi.get(self, \"mode\")",
"def get_mode(self):\r\n return self.mode",
"def cu... | [
"0.7658945",
"0.7552529",
"0.7548578",
"0.7548578",
"0.7477973",
"0.73740226",
"0.7363553",
"0.7352882",
"0.7321897",
"0.7321897",
"0.72539693",
"0.7151159",
"0.7151159",
"0.7151159",
"0.7148779",
"0.7146024",
"0.7146024",
"0.7146024",
"0.7132851",
"0.7081131",
"0.70633066",
... | 0.7637281 | 1 |
Return the current thermostat fan level. | def get_thermostat_fan_level(self) -> ThermostatFanLevel:
hex_level = hexlify(self.message[140:141]).decode()
states = dict(map(lambda s: (s.value, s), ThermostatFanLevel))
return states[hex_level[0:1]] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_fan_mode(self):\n fan_speed = self.data.get(\"windspeed\")\n if fan_speed is None:\n return None\n if fan_speed == \"1\":\n return \"low\"\n elif fan_speed == \"2\":\n return \"medium\"\n elif fan_speed == \"3\":\n return \"... | [
"0.74703616",
"0.7066224",
"0.68729824",
"0.68550014",
"0.67621636",
"0.6755983",
"0.67260545",
"0.67260545",
"0.67141235",
"0.66230714",
"0.65797645",
"0.6569751",
"0.64834934",
"0.6479434",
"0.64644015",
"0.64276075",
"0.6419574",
"0.63961965",
"0.63904285",
"0.6337175",
"0... | 0.7609413 | 0 |
Return the current thermostat fan swing. | def get_thermostat_swing(self) -> ThermostatSwing:
hex_swing = hexlify(self.message[140:141]).decode()
return (
ThermostatSwing.OFF
if hex_swing[1:2] == ThermostatSwing.OFF.value
else ThermostatSwing.ON
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_fan_mode(self):\n fan_speed = self.data.get(\"windspeed\")\n if fan_speed is None:\n return None\n if fan_speed == \"1\":\n return \"low\"\n elif fan_speed == \"2\":\n return \"medium\"\n elif fan_speed == \"3\":\n return \"... | [
"0.70957595",
"0.6493973",
"0.631704",
"0.63008916",
"0.6264081",
"0.6264081",
"0.6234834",
"0.62224776",
"0.6185605",
"0.6077536",
"0.604315",
"0.6022031",
"0.6020563",
"0.6006388",
"0.5999204",
"0.5998517",
"0.59481037",
"0.59452474",
"0.59378165",
"0.592065",
"0.59011304",... | 0.68038505 | 1 |
Find a node marked with the given pattern, "targetPattern", in a DOM object, "someStan" | def findPattern(someStan, targetPattern):
pat = getattr(someStan, 'pattern', None)
if pat == targetPattern:
return someStan.cloneNode()
for child in getattr(someStan, 'children', []):
result = findPattern(child, targetPattern)
if result is not None:
return result.cloneNod... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_target(self, target):\n components = target.split(':', maxsplit=1)\n if len(components) == 1:\n namespace = ''\n target_name = components[0]\n else:\n namespace = components[0]\n target_name = components[1]\n\n logging.info(f\"Finding... | [
"0.5607359",
"0.55932343",
"0.5582585",
"0.5578958",
"0.55475706",
"0.54207045",
"0.5325378",
"0.52941066",
"0.5246212",
"0.5242798",
"0.5218119",
"0.5108456",
"0.5108017",
"0.5065287",
"0.5042875",
"0.5022458",
"0.5019698",
"0.5003935",
"0.4971588",
"0.49277413",
"0.492709",... | 0.77453876 | 0 |
Call this to register a converter for one of your custom types. | def registerConverter(convertType, converter):
converters[convertType] = converter | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_converter(self, converter, conv_type, conv_format=None):\n self.flask_plugin.register_converter(converter, conv_type, conv_format)",
"def addCustomConverter(self, converter):\r\n verifyClass(ICustomROSConverter, converter)\r\n\r\n if converter.MESSAGE_TYPE in self._customTypes:\... | [
"0.7982891",
"0.7092699",
"0.69731474",
"0.6862946",
"0.65146774",
"0.6331026",
"0.61889535",
"0.6141865",
"0.61362225",
"0.60911644",
"0.59488845",
"0.5865866",
"0.5849205",
"0.5760711",
"0.5654728",
"0.5608014",
"0.5556543",
"0.55253804",
"0.5516893",
"0.54477257",
"0.54117... | 0.8012467 | 0 |
Recursively apply stuff converters until we get an xml instance. | def convert(request, stuff):
while not isinstance(stuff, xml):
convert = converters.get(type(stuff))
if convert is None:
raise RuntimeError, "Converter for type %r (%r) not found." % (
type(stuff), stuff)
stuff = convert(request, stuff)
return stuff.string | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def converters(self) -> Iterator[Tuple[str, Type[ConverterAPI]]]:",
"def auto_convert(self):\n nodes_converted = []\n for node_type in self.conversion_spec_sheet:\n print('searching for: %s' % node_type)\n found_nodes = self.list_nodes(node_type)\n print('found: %s ... | [
"0.54154575",
"0.5362358",
"0.5302721",
"0.52521217",
"0.5242494",
"0.5195388",
"0.51844907",
"0.5166652",
"0.51354116",
"0.5108349",
"0.50608504",
"0.50423545",
"0.50373363",
"0.5032745",
"0.5002228",
"0.49851438",
"0.49840027",
"0.48968914",
"0.48965812",
"0.4865027",
"0.48... | 0.7087699 | 0 |
_clear_child_ deletes this object's 'child_' attribute, then loops through all this object's attributes, and recursively calls the _clear_child method of any child_ attributes | def _clear_child_(self):
try:
del self.child_
except AttributeError, e:
pass
for attr in filter(self._child_re.match, dir(self)):
try:
getattr(self, attr)._clear_child_()
except AttributeError:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup(child):\n children = child.get('children', [])\n for childchild in children:\n cleanup(childchild)\n cleaned = {u'title': child['Title'], u'name': child['id'],\n u'children': children}\n child.clear()\n child.update(cleaned)",
"def deep_... | [
"0.7398926",
"0.65832293",
"0.64992577",
"0.64653677",
"0.64382654",
"0.63919705",
"0.63272446",
"0.620319",
"0.6158226",
"0.6155242",
"0.61202127",
"0.6109521",
"0.60912627",
"0.60892636",
"0.6071417",
"0.60680395",
"0.60535574",
"0.6002126",
"0.59893113",
"0.5987409",
"0.59... | 0.8680944 | 0 |
This Resource is about to handle a request. If it wants to delegate to another Resource, it can return it here. | def willHandle(self, request):
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handler(self):\n\t\treturn self.handle_request",
"def handle_request(self, request):\n return self._first_handler(self, request)",
"def __call__(self, *args, **kwargs):\n\t\treturn self.handler()(self.request(kwargs))",
"def process(self, user, request, resource, path, meta):\n raise ValueE... | [
"0.67229843",
"0.6442055",
"0.63741136",
"0.62232375",
"0.61168444",
"0.61049634",
"0.6079845",
"0.6040411",
"0.60218996",
"0.6000085",
"0.5869706",
"0.58631307",
"0.58325726",
"0.5815255",
"0.5810135",
"0.5737306",
"0.5734817",
"0.5728726",
"0.5722223",
"0.572133",
"0.570856... | 0.67254317 | 0 |
post Override this to handle a form post. Return a URL to be redirected to. | def post(self, request, form):
return request.uri() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(self, request):\n user = self._authenticate(request)\n is_valid = self._validate_user(request, user)\n if user and is_valid:\n login(request, user)\n url = request.POST.get('next', '/')\n print request.POST\n return redirect(url)\n re... | [
"0.6832064",
"0.67205185",
"0.64404494",
"0.6379828",
"0.63197786",
"0.63160264",
"0.62764686",
"0.62760127",
"0.6269952",
"0.62224627",
"0.6205702",
"0.61954165",
"0.6178908",
"0.6143098",
"0.61342144",
"0.6116767",
"0.6080857",
"0.6053228",
"0.60354316",
"0.60266346",
"0.60... | 0.72291327 | 0 |
Flying wing with winglets. | def flying_wing(sections):
_wing = wl.FlyingWing(sections=sections, winglet_parameters=None)
_wing.create_wing_planform()
return _wing | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wing(self):\n return",
"def flying_wing_winglets(sections):\n\n SPAN = WingletParameters.SPAN.value\n ANGLE_CANT = WingletParameters.ANGLE_CANT.value\n ANGLE_SWEEP = WingletParameters.ANGLE_SWEEP.value\n ANGLE_TWIST_ROOT = WingletParameters.ANGLE_TWIST_ROOT.value\n ANGLE_TWIST_TIP = Win... | [
"0.66285217",
"0.6478682",
"0.6104694",
"0.5966311",
"0.5959964",
"0.5788519",
"0.57147986",
"0.56718796",
"0.56633484",
"0.5654964",
"0.5629386",
"0.5615403",
"0.5604028",
"0.5589418",
"0.5578025",
"0.5567017",
"0.55469376",
"0.55456835",
"0.5537543",
"0.54950386",
"0.549377... | 0.6692536 | 0 |
Test the sections are sorted in the correct order. | def test_instantiate_wing_sort_sections(sections):
expected_sections = copy.deepcopy(sections)
# Swap sections order
swap = copy.deepcopy(sections[1])
sections[1] = sections[0]
sections[0] = swap
# Instantiate
wing = FlyingWing(sections=sections, winglet_parameters=None)
# Check the ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_order(self, filename: str, section: str, texts: List[str]):\n alphas = sorted(texts, key=lambda x: x.split(':')[0].lower())\n if texts == alphas:\n return\n for text, alpha in zip(texts, alphas):\n if text != alpha:\n print(f'{filename}: {section}... | [
"0.6678625",
"0.65117383",
"0.64006776",
"0.63972",
"0.6224504",
"0.6207259",
"0.6120042",
"0.6104729",
"0.5975373",
"0.5969546",
"0.5953876",
"0.59147906",
"0.590727",
"0.5897399",
"0.5894756",
"0.58860564",
"0.5871923",
"0.5813467",
"0.580579",
"0.58002204",
"0.5794069",
... | 0.6723676 | 0 |
Prepare the file locker. Specify the file to lock and optionally the maximum timeout and the delay between each attempt to lock. | def __init__(self, file_name, timeout=10, delay=.05):
self.is_locked = False
self.lockfile = os.path.abspath(file_name)
self.file_name = file_name
self.timeout = timeout
self.delay = delay
self.fd = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, file_name, timeout=10, delay=.05):\r\n self.is_locked = False\r\n #self.lockfile = os.path.join(os.getcwd(), \"%s.lock\" % file_name)\r\n self.lockfile = file_name + '.lock'\r\n self.file_name = file_name\r\n self.timeout = timeout\r\n self.delay = delay... | [
"0.7275898",
"0.6982331",
"0.6930079",
"0.67412364",
"0.6593794",
"0.64104044",
"0.63795364",
"0.6343358",
"0.6310697",
"0.6309369",
"0.6213117",
"0.60422367",
"0.5983077",
"0.59159404",
"0.58600146",
"0.5779379",
"0.5777742",
"0.5752242",
"0.56741214",
"0.56453484",
"0.56215... | 0.7269806 | 1 |
View the content of the given `TreeManager` in the LSpace eco_viewer tool | def view_in_lspace(tree_manager, lspace_root=None):
node = tree_manager.lines[0].node # first node
doc = EcoDoc()
while True:
node = node.next_term
if isinstance(node.symbol, IndentationTerminal):
continue
if isinstance(node, EOS):
lbnode = tree_manager.get_la... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def View_Tree_1(self):\r\n self.system.Set_Tree_View_Mode(1)",
"def tree():\n nobv.visual_tree()",
"def View_Tree_2(self):\r\n self.system.Set_Tree_View_Mode(2)",
"def View_Tree_3(self):\r\n self.system.Set_Tree_View_Mode(3)",
"def treeExplorer(**kwds):\n from .TreeExplorer impor... | [
"0.6410106",
"0.62578595",
"0.6140295",
"0.6094907",
"0.5861213",
"0.5749762",
"0.5636365",
"0.5575719",
"0.5533464",
"0.55283636",
"0.5482779",
"0.5446668",
"0.5417185",
"0.5394786",
"0.5394212",
"0.53881365",
"0.5326237",
"0.53217983",
"0.53179187",
"0.5317833",
"0.53139853... | 0.7159866 | 0 |
Upgrade Nodes if mixed_version is True, only upgrade those nodes that are specified by nodes, otherwise ignore nodes specified and upgrade all nodes. | def upgrade_to_version(self, version, mixed_version=False, nodes=None):
debug('Upgrading to ' + version)
if not mixed_version:
nodes = self.cluster.nodelist()
for node in nodes:
debug('Prepping node for shutdown: ' + node.name)
node.flush()
self._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_nodes(self):\n raise NotImplementedError('ERROR: sweeper has to implement update_nodes(self)')",
"def update_nodes(self, weights=None, hive_instance=None):\n hive = hive_instance or shared_hive_instance()\n metadata = None\n account = None\n cnt = 0\n while me... | [
"0.5882777",
"0.5731162",
"0.56259555",
"0.5442896",
"0.5395769",
"0.5358854",
"0.5262287",
"0.5247419",
"0.524426",
"0.5210196",
"0.51772773",
"0.51600504",
"0.51503044",
"0.5118009",
"0.5094011",
"0.5081805",
"0.50662416",
"0.5063596",
"0.5050908",
"0.50414723",
"0.49989244... | 0.7341229 | 0 |
raise exception if environment variable is not set | def check_envvar(envvar):
if not os.environ.get(envvar):
raise EnvironmentError("Variable '%s' not set" % envvar) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getenv_check(e):\n res = os.getenv(e)\n if res == None:\n print(e, 'environment variable not set - stopping.')\n exit(1)\n else:\n return res",
"def _check_env():\n\tif os.getenv(_DATA_DIRECTORY_ENV_KEY) is None:\n\t\texit_everything(ERROR_DATA_DIRECTORY_NOT_SET, f'{_DATA_DIRECT... | [
"0.7693455",
"0.75979894",
"0.7594372",
"0.74920285",
"0.74750453",
"0.7391544",
"0.7008469",
"0.69389886",
"0.69301397",
"0.6909712",
"0.685651",
"0.6856387",
"0.68016106",
"0.6705088",
"0.6686351",
"0.6683706",
"0.6681883",
"0.6654641",
"0.66065437",
"0.65902627",
"0.657680... | 0.8079858 | 0 |
load created json files to S3 bucket | def upload(jsonfiles):
# clear S3 Bucket
bucket = S3Bucket()
bucket.clear()
for jsonfile in jsonfiles:
filename = os.path.basename(jsonfile)
key = build_key(filename)
logging.info("%s %s", filename, key)
# store json in S3 object
bucket.store(key, jsonfile) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _s3_stash(self):\n s3_url = 's3://{}/{}'.format(BUCKET, self.atom_file)\n bucketpath = BUCKET.strip(\"/\")\n bucketbase = BUCKET.split(\"/\")[0]\n parts = urlparse.urlsplit(s3_url)\n mimetype = 'application/xml' \n \n conn = boto.connect_s3()\n\n try:\n ... | [
"0.6985121",
"0.69683963",
"0.6922932",
"0.6861065",
"0.685234",
"0.66070056",
"0.65758073",
"0.6551769",
"0.6550309",
"0.65369016",
"0.64492005",
"0.6376597",
"0.6289341",
"0.6281992",
"0.6274749",
"0.62634486",
"0.6242343",
"0.6241593",
"0.62215537",
"0.6221003",
"0.6214576... | 0.7573898 | 0 |
Convert the code to a list of positions. E.g. "12" returns [1,2] | def codeToPositions(self, positions_code):
# Pull out positions from the code
requested_positions = []
for i in range(len(positions_code)):
this_position = int(positions_code[i])
requested_positions.append(this_position)
return requested_positions | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_pos(self, pos):\r\n\r\n column = ord(pos[0]) - 97\r\n if len(pos) == 2:\r\n row = ord(pos[1]) - 49\r\n else:\r\n row = 9\r\n return [row, column]",
"def toPosition(self, pos):\n return [ord(pos[0])-ord('a'), int(pos[1])]",
"def toPosition(self,... | [
"0.6843231",
"0.6796919",
"0.6796919",
"0.6607168",
"0.65984535",
"0.6562776",
"0.6543961",
"0.644775",
"0.6356751",
"0.6204404",
"0.61959976",
"0.60942286",
"0.6035776",
"0.5963504",
"0.5939585",
"0.59067464",
"0.59013224",
"0.5897137",
"0.58854824",
"0.588048",
"0.5863592",... | 0.76894224 | 0 |
Convert the state to a code. E.g. state 1 could be "01", depending on the servo setup | def stateToCode(self, state):
multiplier = 1
code = ""
for i in range(self.num_joints-1, -1, -1):
num_angles = len(self.angles[i])
code += str(int((state / multiplier ) % num_angles))
multiplier *= len(self.angles[i])
# Return the reversed code
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_state_code(self, data) -> int:\n return int(self.state)",
"def state_to_string(board_state):\n return str(board_state)",
"def _status_to_state(status):\n if status == 'failed':\n return Finding.State.ACTIVE\n elif status == 'passed' or status == 'skipped':\n return Finding.State.INAC... | [
"0.7099449",
"0.64658976",
"0.6341494",
"0.630235",
"0.6236514",
"0.61942995",
"0.61780244",
"0.61468345",
"0.6120422",
"0.6093492",
"0.6093492",
"0.6088677",
"0.6056049",
"0.6005784",
"0.59579587",
"0.5882401",
"0.5843271",
"0.58395547",
"0.58130515",
"0.58092207",
"0.580722... | 0.74284816 | 0 |
Generates a sample of measures, to be fed into the neural net. sample_size is the number of distinct images of measures multiplicity is the number of times that measure should be augmented, so the actual samples size is sample_sizemultiplicity sample_name is the name of the folder in which the sample data is deposited ... | def generate_sample(sample_size, multiplicity, sample_name, height, width, treble_tp_key, bass_tp_key, treble_cp_key, bass_cp_key, rest_prob, measure_length_choices=(8, 12, 16), key_number_choices=tuple(range(-7, 8))):
t = time.time()
if not os.path.exists(sample_name + '/'):
os.mkdir(sample_name +... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_samples(self, n_samples):",
"def generate_samples(self, n_samples):",
"def sample(self, size=1):\n raise NotImplementedError",
"def sample(self, size=1):\n raise NotImplementedError",
"def sample(self, size=1):\n raise NotImplementedError",
"def sample(self, size=1):\n ... | [
"0.64130974",
"0.64130974",
"0.6090398",
"0.6090398",
"0.6090398",
"0.6090398",
"0.6069997",
"0.60332435",
"0.59508437",
"0.59355867",
"0.58917224",
"0.5861272",
"0.58172125",
"0.5764265",
"0.57515836",
"0.5744843",
"0.5720441",
"0.5713661",
"0.5708281",
"0.5684648",
"0.56315... | 0.78432107 | 0 |
Create a GeneticInstance from the GUI parameters | def createGeneticInstance(self, context):
genetic_instance = GeneticInstance(ParametricLSystem(self.seed))
fromBlenderToGeneticInstance(self,genetic_instance)
return genetic_instance | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, params, fitness, population_size=20, generations=20, temperature_factor=0.9):\n self.params = params\n self.fitness = fitness\n self.population_size = population_size\n self.generations = generations\n self.temperature_factor = temperature_factor\n\n sel... | [
"0.5936202",
"0.5764224",
"0.5752127",
"0.57048696",
"0.56787145",
"0.5638419",
"0.5532541",
"0.55181456",
"0.54791015",
"0.54660714",
"0.5462964",
"0.54509676",
"0.5433748",
"0.54269344",
"0.5425451",
"0.5401366",
"0.5400063",
"0.539114",
"0.53665835",
"0.53568083",
"0.53527... | 0.7237641 | 0 |
Construct a 95% confidence ellipse using PCA. | def ci95_ellipse(data, type="pop"):
# Build and fit PCA model
pca = PCA()
pca.fit(data)
coeff = pca.components_
score = pca.transform(data)
eigvals = pca.explained_variance_
# Calculate rotation angle
phi = math.atan2(coeff[0, 1], coeff[0, 0])
# This angle is between -pi and pi.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pca(data):\n mean = data.sum(axis=0) / data.shape[0]\n # show_image(mean)\n cv_matrix = np.cov(data.T)\n e_values, e_vectors = la.eig(cv_matrix)\n return e_values, e_vectors.T, mean",
"def pca(X = Math.array([]), no_dims = 50):\n\n print \"Preprocessing the data using PCA...\"\n (n, d) =... | [
"0.71092635",
"0.64815754",
"0.64644057",
"0.6348164",
"0.6333782",
"0.63307154",
"0.6305946",
"0.62970555",
"0.6267798",
"0.6267798",
"0.6267798",
"0.6246083",
"0.6168096",
"0.61434823",
"0.603798",
"0.60196155",
"0.6015497",
"0.6015308",
"0.5967477",
"0.59300923",
"0.581831... | 0.75360584 | 0 |
Create a control for each property in the videobalance widget | def customWidgets(self):
# to be called a property value needs to change
def onValueChanged(widget, prop):
# set the corresponding property of the videobalance element
self.balance.set_property(prop, widget.get_value())
# videobalance has several properties, wit... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toControls(self,widget):",
"def fromControls(self,widget):",
"def getControls(self):",
"def create_widgets(self):",
"def create_widgets( self ):",
"def CreateControls(self, propgrid, property, pos, sz):\n try:\n x, y = pos\n w, h = sz\n h = 64 + 6\n\n ... | [
"0.70154065",
"0.65180445",
"0.6351398",
"0.6309845",
"0.6266637",
"0.6256561",
"0.6011848",
"0.5990534",
"0.5953611",
"0.5917834",
"0.5880908",
"0.57732254",
"0.57251745",
"0.5692181",
"0.5686156",
"0.5669572",
"0.5639852",
"0.5622619",
"0.5615317",
"0.56069106",
"0.55989015... | 0.74142814 | 0 |
Force all list calls after this to return 'consistent' results. You should generally not call this from your application logic; instead, your application code should handle inconsistent lists gracefully. | def force_consistent_list(self):
self._force_consistent_list = True
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _filter_results_for_eventual_consistency(self, results):\n if self.list_count > self.NUM_INCONSISTENT_LISTS:\n return results\n else:\n num_remaining_lists = self.NUM_INCONSISTENT_LISTS - self.list_count\n # Don't start from offset of 0, so short lists (which will... | [
"0.6987481",
"0.6444678",
"0.58526874",
"0.58275646",
"0.57697743",
"0.57474655",
"0.56870705",
"0.56703025",
"0.5668953",
"0.56320864",
"0.56245184",
"0.5613652",
"0.5580343",
"0.55586827",
"0.5510964",
"0.549497",
"0.54739416",
"0.54650426",
"0.5443179",
"0.54411036",
"0.54... | 0.74617606 | 0 |
Simulates S3's eventual consistency by filtering out items from the result set. Results are filtered out by only returning every nth result. This has the nice property of interleaving returned results, so consumers can't make assumptions that treat S3 lists as append only. The initial list call also won't return any re... | def _filter_results_for_eventual_consistency(self, results):
if self.list_count > self.NUM_INCONSISTENT_LISTS:
return results
else:
num_remaining_lists = self.NUM_INCONSISTENT_LISTS - self.list_count
# Don't start from offset of 0, so short lists (which will be more
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testRetrievingWithoutSpecifyingLimit(self):\n cached_items = cached_list_logic.getCachedItems('test_list', start=2)\n self.assertListEqual([self.item3, self.item4, self.item5], cached_items)",
"def testRetrievingWithoutSpecifyingStart(self):\n cached_items = cached_list_logic.getCachedItems('test_li... | [
"0.60967356",
"0.59897625",
"0.57029206",
"0.5662621",
"0.53988785",
"0.5391997",
"0.5382999",
"0.5382957",
"0.5312985",
"0.5295677",
"0.52932",
"0.52842057",
"0.5268883",
"0.5228543",
"0.5221372",
"0.5189532",
"0.5145578",
"0.50993717",
"0.5041751",
"0.5038586",
"0.50338745"... | 0.6864502 | 0 |
Convenience function to tack on columns that are necessary for the functionality of the tool but yet have not been specifically requested by the user. | def _add_necessary_columns(args, custom_columns):
# we need to add the variant's chrom, start and gene if
# not already there.
if custom_columns.find("gene") < 0:
custom_columns += ", gene"
if custom_columns.find("start") < 0:
custom_columns += ", start"
return custom_colum... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _these_columns_cannot_annotate_exp_cons(self):\n _cols = set([]) #\n for param_name, req_cols in self.required_columns.items():\n _cols |= req_cols\n\n return _cols | self.other_useful_columns",
"def columns_setup(self):\n self.required = None\n self.addition = ... | [
"0.7042445",
"0.6572701",
"0.6462197",
"0.6344353",
"0.63297266",
"0.6177399",
"0.61261445",
"0.6061339",
"0.60574806",
"0.6044095",
"0.60419595",
"0.59884024",
"0.59808314",
"0.59711903",
"0.5969461",
"0.59672695",
"0.5959676",
"0.5954561",
"0.5945721",
"0.59399706",
"0.5923... | 0.75083494 | 0 |
Report candidate compound heterozygous mutations. | def get_compound_hets(args):
gq = GeminiQuery.GeminiQuery(args.db, include_gt_cols=True)
idx_to_sample = gq.idx_to_sample
subjects_dict = subjects.get_subjects(gq.c)
if args.columns is not None:
custom_columns = _add_necessary_columns(args, str(args.columns))
query = "SELECT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_mutation(self):\n genotype = '0|0|2|0|0|2|0|0 1|0|0|1|1|0|0|0 0|1|0|0|0|0|2|1--1 7'\n search_space = {'dil_conv_3x3', 'dil_conv_5x5', 'dil_conv_7x7',\n 'skip_connect', 'clinc_3x3', 'clinc_7x7', 'avg_pool_3x3', 'max_pool_3x3'}\n\n mutator = Mutations(search_s... | [
"0.5473835",
"0.54621196",
"0.5410071",
"0.5340635",
"0.53035814",
"0.53019184",
"0.5292105",
"0.5210743",
"0.5179937",
"0.5177363",
"0.51658905",
"0.5165434",
"0.51492155",
"0.51443344",
"0.5134806",
"0.5133196",
"0.51056236",
"0.5080089",
"0.5078701",
"0.50761664",
"0.50647... | 0.54736185 | 1 |
Install the app base on the source and the destination given. It makes sure that the destination folder does not exist. It then run the checks to see if the installation is completed. | def install(self):
if self.__checkDestination():
if self.__ui:
self.__ui.progressText.append('Destination found, removing it...')
self.__removeFiles(self.__targetPath, verbose=True)
if self.__ui:
self.__ui.progressText.append('Copying files...')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pre_install(self, dest_dir):\n pass",
"def install(src, dst):\n try:\n dst = os.path.join(install_dir, dst, os.path.basename(src))\n src = os.path.join(source_dir, src)\n assert os.path.isfile(src)\n assert not os.path.isdir(dst)\n if not os.path.isdir(os.path.dir... | [
"0.6939311",
"0.67621106",
"0.66896224",
"0.63416165",
"0.6273808",
"0.62601715",
"0.6225733",
"0.60879886",
"0.6076069",
"0.60691816",
"0.60395724",
"0.5985055",
"0.59724474",
"0.59244055",
"0.5914381",
"0.5912949",
"0.5879463",
"0.586991",
"0.5838821",
"0.5827504",
"0.58250... | 0.750132 | 0 |
Copy the files from the source to the destination. At this point it assume that the destination folder does not exist. | def __copyFiles(self):
if os.path.isdir(self.__sourcePath):
shutil.copytree(self.__sourcePath, self.__targetPath)
else:
shutil.copy2(self.__sourcePath, self.__targetPath) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_files(source,destination):\r\n filelist = os.listdir(source)\r\n \r\n if not os.path.exists(destination):\r\n os.mkdir(destination)\r\n \r\n for filename in filelist:\r\n source_file = os.path.join(source,filename)\r\n shutil.copy(source_file,destination)",
"def _copy... | [
"0.7597833",
"0.74374366",
"0.7421489",
"0.74199075",
"0.7275083",
"0.72525555",
"0.7226759",
"0.7090539",
"0.69888306",
"0.6975546",
"0.6959424",
"0.6957595",
"0.69572604",
"0.693605",
"0.68874115",
"0.68684584",
"0.6854901",
"0.6811629",
"0.67662746",
"0.6756434",
"0.675441... | 0.7903018 | 0 |
Check if the destination exist. | def __checkDestination(self):
return os.path.exists(self.__targetPath) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exists(self, destination: Route) -> bool:\n i = hash(destination.addr)\n return i in self.keys()",
"def file_copy_remote_exists(self, src, dest=None, file_system=None):\n self.enable()\n if file_system is None:\n file_system = self._get_file_system()\n\n file_cop... | [
"0.6858912",
"0.6722851",
"0.671514",
"0.64568853",
"0.64418423",
"0.6440546",
"0.6426673",
"0.6364792",
"0.63298523",
"0.6284588",
"0.6248964",
"0.6243041",
"0.6229809",
"0.61921597",
"0.61565524",
"0.613735",
"0.6128297",
"0.6117316",
"0.60820246",
"0.60760295",
"0.60641205... | 0.8561405 | 0 |
Set the destination path. | def setDestinationPath(self, targetPath):
self.__targetPath = targetPath | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dest_path(self, dest_path):\n\n self._dest_path = dest_path",
"def set_destination(self, value):\n try:\n self._destination = value\n self._repository = hg.repository(ui.ui(), self._destination)\n except:\n self._repository = None",
"def destination(sel... | [
"0.7895495",
"0.74544734",
"0.7052994",
"0.67628735",
"0.6749421",
"0.66697735",
"0.664493",
"0.6620139",
"0.6620139",
"0.6620139",
"0.6620139",
"0.6620139",
"0.66084516",
"0.6494985",
"0.6414038",
"0.6353641",
"0.63524634",
"0.63138354",
"0.6285127",
"0.62720805",
"0.6261273... | 0.8375323 | 0 |
Set the source path. | def setSourcePath(self, sourcePath):
self.__sourcePath = sourcePath | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_source_path(self, folder):\n self.source_path = folder",
"def set_source_file(self, source_file):\n self.set_attribute(\"source_file\", source_file)",
"def set_source(self, source):\n self.data['source'] = source",
"def set_source(self, source_name):\n self.source = source... | [
"0.7961063",
"0.75596577",
"0.7289281",
"0.7227081",
"0.70959604",
"0.70959604",
"0.70959604",
"0.70959604",
"0.70959604",
"0.70959604",
"0.70959604",
"0.7083602",
"0.70523936",
"0.6990167",
"0.694741",
"0.6841845",
"0.6805303",
"0.6765955",
"0.6750728",
"0.6708304",
"0.67082... | 0.8587527 | 0 |
Return hash derived from the the call stack filename and location | def caller_hash(depth:int=1, prefix:str='#') -> str:
caller = getframeinfo(stack()[depth+1][0])
str = f"{caller.filename}/{caller.lineno}"
_hash = hash(str)
_hash += sys.maxsize + 1
return prefix + hex(_hash)[2:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_hash(self) -> str:\n if self.call_hash:\n # Derived state from a call_node.\n return hash_struct([\"Handle\", self.fullname, \"call_hash\", self.key, self.call_hash])\n else:\n # Initial state.\n return hash_struct([\"Handle\", self.fullname, \"init... | [
"0.7092891",
"0.7029913",
"0.6900932",
"0.6653355",
"0.6600427",
"0.6556791",
"0.653537",
"0.6502056",
"0.64829963",
"0.64236236",
"0.63612115",
"0.6338636",
"0.630916",
"0.6291573",
"0.6283543",
"0.6251896",
"0.62413055",
"0.6219128",
"0.6216642",
"0.61987674",
"0.61952037",... | 0.79158044 | 0 |
Devolve n! (n fatorial) >>> fatorial(1) 1 >>> fatorial(5) 120 >>> fatorial(30) 265252859812191058636308480000000L | def fatorial(n):
if n <= 1: return 1
return n * fatorial(n-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deconvolve(num, den, n=None):\n num = np.atleast_1d(num)\n den = np.atleast_1d(den)\n N = len(num)\n D = len(den)\n if D > N and n is None:\n quot = []\n rem = num\n else:\n if n is None:\n n = N - D + 1\n input = np.zeros(n, float)\n input[0] = 1... | [
"0.6400818",
"0.590391",
"0.58923686",
"0.5881932",
"0.5868089",
"0.57699984",
"0.57487494",
"0.5739737",
"0.57129353",
"0.5664286",
"0.56454784",
"0.56116253",
"0.55943865",
"0.5588568",
"0.5585924",
"0.55539",
"0.55361503",
"0.55334914",
"0.55174816",
"0.5490245",
"0.547871... | 0.6433339 | 0 |
Greets the user with the parameter as the phrase | def greeter():
name = input("What is your name? ")
print("\nMarvin says:\n")
print("Hello %s - your awesomeness!" % name)
print("What can I do you for?!") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def greet_player(name):\n\t\n\tprint \"How are are you doing %s?\" % name",
"def greet_user(username):\n print(\"Hello, \" + username + \"!\")",
"def greet_user(username):\r\n print(\"Hello, \" + username + \"!\")",
"def greet_user(username):\n print(\"Hello, \" + username.title() + \"!\")",
"def ... | [
"0.714194",
"0.70204103",
"0.7017552",
"0.697279",
"0.697279",
"0.6967602",
"0.6929661",
"0.6916902",
"0.6748197",
"0.6707344",
"0.6688582",
"0.66677773",
"0.6619989",
"0.66091704",
"0.6571961",
"0.65656203",
"0.65656203",
"0.65656203",
"0.6558656",
"0.65458745",
"0.6540771",... | 0.7055033 | 1 |
Multiplies number with word | def multiply(number, word):
return int(number) * word | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_multiplier_words(number, word, language_data):\n required_part = word.split(\"<\")[-1]\n if required_part[0] != \" \":\n return\n\n power_of_10 = _count_zero(number)\n if \"$\" in required_part:\n valid_words = re.findall(CAPTURE_BRACKET_CONTENT, required_part)\n for valid... | [
"0.7133484",
"0.70913893",
"0.6875895",
"0.669992",
"0.66984",
"0.65846294",
"0.6558947",
"0.6519726",
"0.6497288",
"0.6497288",
"0.63721395",
"0.6366141",
"0.6305392",
"0.62679416",
"0.62597495",
"0.62541693",
"0.6243564",
"0.6230531",
"0.6230531",
"0.62106043",
"0.61858195"... | 0.86316043 | 0 |
Compares input number with the latest number | def compare_numbers():
compareOld = None
while True:
compareInput = input("Please provide a number. Quit with 'done'")
if compareInput == 'done':
break
try:
compareNumber = int(compareInput)
if compareOld is None:
print("This... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_smallest_number_with_last_digit_equal_to_an_input_digit():\n assert smallest_number_with_last_digit_equal_to_an_input_digit([1, 6, 34, 68, 40, 48, 20], 8) == 48\n assert smallest_number_with_last_digit_equal_to_an_input_digit([1, 2, 3], 3) == 3\n assert smallest_number_with_last_digit_equal_to_an... | [
"0.6480286",
"0.6474917",
"0.6066898",
"0.60084206",
"0.58431",
"0.58227915",
"0.58031726",
"0.5782954",
"0.5781479",
"0.5774768",
"0.57605845",
"0.57545424",
"0.57125413",
"0.5712499",
"0.5703884",
"0.5632079",
"0.56003505",
"0.5598331",
"0.5588869",
"0.5585761",
"0.5567629"... | 0.6772036 | 0 |
Modifies an input string | def modify_string():
modString = input("Please write a string. ")
modNewStr = ""
modCount = 1
for letter in modString:
if modCount < 2:
modNewStr = letter
else:
modNewStr = modNewStr + "-" + letter * modCount
modCount += 1
print("New string: ",... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_text(str_in):\n str_out = get_model().replace(str_in)\n get_model().inc_call_counter()\n return str_out",
"def mutStr(st):\n\tl = len(st)\n\tci = randomInt(0, l - 1)\n\tcv = st[ci]\n\tif cv.isdigit():\n\t\tr = selectRandomFromList(dig)\n\telif cv.isupper():\n\t\tr = selectRandomFromList(ucc)... | [
"0.6333922",
"0.5938327",
"0.59197223",
"0.59008723",
"0.5891288",
"0.5889071",
"0.5888334",
"0.58578706",
"0.58334684",
"0.58226764",
"0.5804948",
"0.5804034",
"0.5773653",
"0.57354724",
"0.5726661",
"0.5689621",
"0.5688094",
"0.56491864",
"0.56426936",
"0.55888075",
"0.5581... | 0.6682068 | 0 |
Picks the upper case letters and concatenates them into a new string | def akronom():
akro_str = input("Write a sentance with both upper case and lower case letters. ")
akronomed_str = ""
for letter in akro_str:
if str.isupper(letter):
akronomed_str += letter
print(akronomed_str) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upper(string):\n new_string = '' # Empty string to append to\n for char in string: # Itterate over each character in user's string\n if char.isalpha() and not char.isupper(): # If the character is an alphabet and not already uppercase\n char = (chr(ord(char) - 32)) # Subtract 32 from it... | [
"0.7568085",
"0.7175322",
"0.7120905",
"0.71035486",
"0.7063931",
"0.7037421",
"0.7026546",
"0.70182836",
"0.6939869",
"0.68284166",
"0.6808109",
"0.6803818",
"0.6799995",
"0.6797273",
"0.6720664",
"0.66864145",
"0.66418535",
"0.66384387",
"0.66032445",
"0.6589709",
"0.658928... | 0.74459803 | 1 |
Masks a string of numbers with but leaves the last 4 digits | def str_mask():
mask_input = input("Provide a long number. ")
mask_length = len(mask_input)
last4 = mask_input[-4:]
mask = multiply(mask_length - 4, "#")
masked_str = mask + last4
print(masked_str) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_phone(number):\n numberlist = re.findall(\"\\d\",number)\n new_number = \"\".join(numberlist)\n if len(new_number) == 8:\n \tnew_number = \"010\" + new_number\n\tnew_number = new_number[-11:]\n\tif new_number.startswith('1'):\n\t\tnew_number = \"+86-\" + new_number\n\telse:\n\t\tnew_number = ... | [
"0.67827255",
"0.67305297",
"0.67131793",
"0.65890765",
"0.64678043",
"0.6460441",
"0.64570034",
"0.63391024",
"0.6272115",
"0.6179286",
"0.615589",
"0.61505246",
"0.60001665",
"0.59832764",
"0.5979442",
"0.5976167",
"0.59505975",
"0.5931693",
"0.5921734",
"0.5915949",
"0.590... | 0.7082807 | 0 |
Returns the Python source for this file, if it is available, or None if it is not. | def _read_source(self):
if self.fileType == FTPythonCompiled or \
self.fileType == FTCompiledModule:
return None
filename = Filename(self.filename)
filename.setExtension('py')
try:
file = open(filename, 'rU')
except IOError:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getsourcefile(object):\r\n filename = getfile(object)\r\n if string.lower(filename[-4:]) in ('.pyc', '.pyo'):\r\n filename = filename[:-4] + '.py'\r\n for suffix, mode, kind in imp.get_suffixes():\r\n if 'b' in mode and string.lower(filename[-len(suffix):]) == suffix:\r\n # Lo... | [
"0.71008605",
"0.7004",
"0.69255656",
"0.6722575",
"0.67026246",
"0.67018044",
"0.65404385",
"0.6464617",
"0.6464617",
"0.64623195",
"0.64467514",
"0.6408846",
"0.62653047",
"0.6264861",
"0.6234833",
"0.6153612",
"0.608844",
"0.605979",
"0.60058707",
"0.6003805",
"0.60012",
... | 0.77578664 | 0 |
Returns the Python compiled code object for this file, if it is available, or None if it is not. | def _read_code(self):
if self.fileType == FTPythonCompiled:
# It's a pyc file; just read it directly.
pycVfile = vfs.getFile(self.filename, False)
if pycVfile:
return self._loadPyc(pycVfile, None)
return None
elif self.fileType == FTCompi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def code(self):\r\n if (os.path.exists(self._bytecode_path) and\r\n os.path.getmtime(self.full_path) <= os.path.getmtime(self._bytecode_path)):\r\n with open(self._bytecode_path, 'rb') as bytecode:\r\n return marshal.load(bytecode)\r\n else:\r\n with open(self.full_path, 'rb') as sour... | [
"0.75335735",
"0.7469139",
"0.7044674",
"0.67842853",
"0.67842853",
"0.6689265",
"0.66375077",
"0.6616381",
"0.6603935",
"0.65416414",
"0.6507916",
"0.65020955",
"0.64757884",
"0.64366883",
"0.6418413",
"0.6334043",
"0.623301",
"0.61632675",
"0.6077583",
"0.5995937",
"0.59553... | 0.8227531 | 0 |
Reads and returns the marshal data from a .pyc file. | def _loadPyc(self, vfile, timestamp):
code = None
f = open(vfile, 'rb')
if f.read(4) == imp.get_magic():
t = struct.unpack('<I', f.read(4))[0]
if not timestamp or t == timestamp:
code = marshal.loads(f.read())
f.close()
return code | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_co_from_dump(data):\n # Read py2exe header\n current = struct.calcsize(b'iiii')\n metadata = struct.unpack(b'iiii', data[:current])\n\n # check py2exe magic number\n # assert(metadata[0] == 0x78563412)\n logging.info(\"Magic value: %x\", metadata[0])\n logging.info(\"Code bytes length... | [
"0.65662557",
"0.6384193",
"0.6341848",
"0.611631",
"0.5743764",
"0.57398134",
"0.5732921",
"0.56879",
"0.55201936",
"0.54984534",
"0.54814845",
"0.5436405",
"0.54362696",
"0.5424923",
"0.540435",
"0.53719556",
"0.5361285",
"0.5304752",
"0.5267074",
"0.52599674",
"0.52564466"... | 0.6452861 | 1 |
Compiles the Python source code to a code object and attempts to write it to an appropriate .pyc file. | def _compile(self, filename, source):
if source and source[-1] != '\n':
source = source + '\n'
code = __builtin__.compile(source, filename.cStr(), 'exec')
# try to cache the compiled code
pycFilename = Filename(filename)
pycFilename.setExtension(pycExtension... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compile(self, source: str, filename: str) -> CodeType:\n return compile(source, filename, \"exec\") # type: ignore",
"def pyo():\n local('python -O -m compileall .')",
"def pyo():\n local('python -O -m compileall .')",
"def _get_codeobj(pyfile):\n from imp import PY_COMPILED, PY_SOURCE\... | [
"0.7162829",
"0.71481526",
"0.71481526",
"0.7095582",
"0.7006457",
"0.69402754",
"0.6847345",
"0.6822981",
"0.6776377",
"0.6746384",
"0.6662565",
"0.6629363",
"0.65639025",
"0.63957757",
"0.6383215",
"0.6376323",
"0.6361882",
"0.626",
"0.62477124",
"0.6155028",
"0.6153046",
... | 0.7598696 | 0 |
Register the VFSImporter on the path_hooks, if it has not already been registered, so that future Python import statements will vector through here (and therefore will take advantage of Panda's virtual file system). | def register():
global _registered
if not _registered:
_registered = True
sys.path_hooks.insert(0, VFSImporter) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_finder(importer, finder):\r\n\r\n existing_finder = _get_finder(importer)\r\n\r\n if not existing_finder:\r\n pkg_resources.register_finder(importer, finder)\r\n else:\r\n pkg_resources.register_finder(importer, ChainedFinder.of(existing_finder, finder))",
"def register_finders():\r\n\r\n # If... | [
"0.6036175",
"0.5240254",
"0.5236929",
"0.51234156",
"0.5085861",
"0.5058323",
"0.5038346",
"0.50234586",
"0.50069255",
"0.4978417",
"0.49670815",
"0.49526778",
"0.48803136",
"0.48607883",
"0.4822473",
"0.4798947",
"0.47953275",
"0.4795149",
"0.47560418",
"0.4753519",
"0.4729... | 0.8060369 | 0 |
Launch an application that reads from a webcam and estimates hand pose at realtime. The captured hand must be the right hand, but will be flipped internally and rendered. | def live_application(capture):
############ output visualization ############
view_mat = axangle2mat([1, 0, 0], np.pi) # align different coordinate systems
window_size = 1080
hand_mesh = HandMesh(config.HAND_MESH_MODEL_PATH)
mesh = o3d.geometry.TriangleMesh()
mesh.triangles = o3d.utility.Vecto... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def launch_webcam(self):\n global face_encoding\n\n # Call the image_import.add_user method which launches the camera and\n # returns the face encodings if a new picture is taken\n face_encoding = image_import.add_user()\n\n # Check if a new image was returned from the add_user m... | [
"0.63754654",
"0.6237571",
"0.6205102",
"0.6102088",
"0.6093408",
"0.60862",
"0.60601264",
"0.60538155",
"0.60299253",
"0.60107696",
"0.5936067",
"0.5913625",
"0.5909038",
"0.5898597",
"0.5890865",
"0.58582836",
"0.57765263",
"0.5755932",
"0.57481176",
"0.5738701",
"0.5699189... | 0.7060998 | 0 |
Splits a nengo Connection into separate exc and inh Connections. | def split_exc_inh(conn, net, exc_synapse, inh_synapse):
net.connections.remove(conn)
solver_set = SolverSet(conn.solver, limit=2)
with net:
conn_exc = nengo.Connection(
conn.pre, conn.post,
solver=PositiveOnly(solver_set),
synapse=exc_synapse,
funct... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_special_connections(self):\n\t\tfor connection in self._infoSpecialConnections:\n\t\t\t# List of source cells ids\n\t\t\tsourcesId = self.cellsId[connection[0]][connection[1]]\n\t\t\t# gather the sources all together\n\t\t\tsourcesId = comm.gather(sourcesId,root=0)\n\t\t\tif rank==0: sourcesId = sum(so... | [
"0.57460886",
"0.5582826",
"0.5544595",
"0.55210364",
"0.54384655",
"0.5425718",
"0.5386172",
"0.5219724",
"0.5060346",
"0.5010697",
"0.49985945",
"0.49559784",
"0.48724976",
"0.4830181",
"0.4822985",
"0.48213017",
"0.48176953",
"0.4799253",
"0.4786793",
"0.47852033",
"0.4778... | 0.7375816 | 0 |
fetches a user accoutn object using guid | def __fetch_user_account(self, guid):
try:
user_account = UserAccount.objects.get(guid=guid)
except Exception as e:
logger.exception(e)
else:
return user_account | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user(id):\n pass",
"def get_one_user():",
"async def fetch_self(self) -> OwnUser:\n return await self.app.rest.fetch_my_user()",
"def get(self, no):\n user = get_a_user(no)\n if not user:\n api.abort(404)\n else:\n return user",
"def getuser(gh, ... | [
"0.661174",
"0.6249013",
"0.6194991",
"0.6135571",
"0.60972863",
"0.60675436",
"0.604731",
"0.5956097",
"0.5941534",
"0.5939436",
"0.59257036",
"0.59254116",
"0.59202766",
"0.5903319",
"0.5896457",
"0.5891398",
"0.5853326",
"0.5843873",
"0.5839033",
"0.5819695",
"0.5809867",
... | 0.74750584 | 0 |
creates a payment object | def __create_payment_object(self, data, direction):
from_account = self.__fetch_user_account(guid=data.get("from_account"))
to_account = self.__fetch_user_account(guid=data.get("to_account"))
payment_obj = Payment.objects.create(
from_account=from_account,
to_account=to_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(**data):\n http_client = HttpClient()\n response, _ = http_client.post(routes.url(routes.PAYMENT_RESOURCE), data)\n return resources.Payment(**response)",
"def create_payment(self, payment_request):\n data = payment_request.serialize()\n random_number = int(datetime.... | [
"0.81836104",
"0.73561925",
"0.721683",
"0.7197337",
"0.70666915",
"0.70559716",
"0.6944051",
"0.69413054",
"0.68027186",
"0.67675555",
"0.6753749",
"0.6652057",
"0.6636959",
"0.6498955",
"0.6483282",
"0.6450776",
"0.64113176",
"0.6373708",
"0.6372573",
"0.63036406",
"0.62837... | 0.79805636 | 1 |
public method for outgoing payment object creation | def create_outgoing_payment(self, data):
payment_obj = self.__create_payment_object(data=data, direction=False)
self.__update_user_account(guid=data.get("from_account"), amount=data.get("amount"), direction=False)
return payment_obj | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __create_payment_object(self, data, direction):\n\n from_account = self.__fetch_user_account(guid=data.get(\"from_account\"))\n to_account = self.__fetch_user_account(guid=data.get(\"to_account\"))\n payment_obj = Payment.objects.create(\n from_account=from_account,\n ... | [
"0.71465117",
"0.69827616",
"0.6701402",
"0.66829276",
"0.66817296",
"0.6674573",
"0.6672829",
"0.6573561",
"0.640586",
"0.64023817",
"0.63429075",
"0.6279454",
"0.6221061",
"0.6155795",
"0.61184585",
"0.61052555",
"0.6012806",
"0.5976966",
"0.59646237",
"0.5943552",
"0.59364... | 0.7246261 | 0 |
Determine the frequencies and normalized eigenvectors of a matrix | def freq_and_modes(matrix, k_over_m):
val, vect = np.linalg.eigh(matrix)
#for different masses, use eig with no h
freq = np.sqrt(val)
return freq, vect | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eigen(M):\n values, vectors = np.linalg.eig(M)\n return values, vectors",
"def get_eigenvectors(self):\n return self.eigenVectors",
"def GetEigenvectors(self):\n\t\treturn self.Solver.GetEigenvectors()",
"def get_eigen_values_and_vectors(matrix, num_values):\n (w, v) = eigen_decomp(matrix... | [
"0.6904609",
"0.6858",
"0.6851799",
"0.6815563",
"0.68081987",
"0.6753682",
"0.66808695",
"0.6597894",
"0.6562375",
"0.6542027",
"0.65396744",
"0.6537718",
"0.65263975",
"0.6518386",
"0.6516741",
"0.65053654",
"0.6428052",
"0.6415041",
"0.63126284",
"0.627554",
"0.6254286",
... | 0.69194525 | 0 |
Function to make a plot of motion of masses as a function of time. The time should be on the vertical axis and the position on the horizontal axis. | def plot_motion_of_masses(x, time, title='bad title'):
# Nothing special about these, but they look nice
x1_equilibrium_pos = 3
x2_equilibrium_pos = 6
x1 = x[:, 0] + x1_equilibrium_pos
x2 = x[:, 1] + x2_equilibrium_pos
plt.plot(x1, time, label='Mass 1')
plt.plot(x2, time, label='M... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_motion(x, y):\n plt.xlabel(\"X Position (m)\")\n plt.ylabel(\"Y Position (m)\")\n plt.plot(x, y)\n plt.show()",
"def plot_x(t, x):\n plt.figure()\n plt.plot(t, x)\n plt.title(\"Vertical position of the skydiver as a function of time\")\n plt.xlabel(\"Time t [s]\")\n plt.ylabel... | [
"0.7269444",
"0.6327164",
"0.5962005",
"0.5897222",
"0.5878594",
"0.58591664",
"0.5845195",
"0.5835746",
"0.5810472",
"0.58035827",
"0.57862294",
"0.57339144",
"0.56806844",
"0.566614",
"0.564614",
"0.5617046",
"0.5595726",
"0.55792063",
"0.5563439",
"0.55550057",
"0.55540186... | 0.78880644 | 0 |
Return True if 'that' is a GrowPopulation and this GrowPopulation has the same value as that GrowPopulation | def __eq__(self, that):
return isinstance(that, GrowPopulation) and self.species_index == that.species_index and \
self.card_trade_index == that.card_trade_index | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, population):\n return self.chromosome_list == population.chromosome_list",
"def __eq__(self, other):\n return isinstance(other, Elongation)\\\n and len(self.xs) == len(other.xs)\\\n and all(self.xs == other.xs) and all(self.ys == other.ys)\\\n and s... | [
"0.65205014",
"0.60275203",
"0.6016418",
"0.5955765",
"0.59035647",
"0.58681065",
"0.5847267",
"0.5844807",
"0.5805479",
"0.57989675",
"0.5784682",
"0.57827413",
"0.57796884",
"0.57624125",
"0.57547325",
"0.57336557",
"0.5731267",
"0.5723152",
"0.5716336",
"0.5712271",
"0.571... | 0.80442977 | 0 |
Parse this population grow action from json to a GrowPopulation | def parse_grow_population(json_grow):
if GrowPopulation.is_valid_pop_grow(json_grow):
return GrowPopulation(json_grow[1], json_grow[2])
else:
raise Exception("Invalid json population grow action") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_proxy_grow_population(json_grow):\n if GrowPopulation.is_valid_proxy_grow(json_grow):\n return GrowPopulation(json_grow[0], json_grow[1])\n else:\n raise Exception(\"Invalid json population grow action\")",
"def is_valid_pop_grow(json_grow):\n return isinstanc... | [
"0.76610595",
"0.5805996",
"0.50387174",
"0.49424437",
"0.4896679",
"0.48292255",
"0.47847217",
"0.4774338",
"0.4707168",
"0.47061458",
"0.46529007",
"0.45922315",
"0.457492",
"0.4555513",
"0.45065725",
"0.4488905",
"0.4473739",
"0.44697726",
"0.44694299",
"0.44630593",
"0.44... | 0.80320364 | 0 |
Parse this population grow action from json to a GrowPopulation | def parse_proxy_grow_population(json_grow):
if GrowPopulation.is_valid_proxy_grow(json_grow):
return GrowPopulation(json_grow[0], json_grow[1])
else:
raise Exception("Invalid json population grow action") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_grow_population(json_grow):\n if GrowPopulation.is_valid_pop_grow(json_grow):\n return GrowPopulation(json_grow[1], json_grow[2])\n else:\n raise Exception(\"Invalid json population grow action\")",
"def is_valid_pop_grow(json_grow):\n return isinstance(json_g... | [
"0.80320364",
"0.5805996",
"0.50387174",
"0.49424437",
"0.4896679",
"0.48292255",
"0.47847217",
"0.4774338",
"0.4707168",
"0.47061458",
"0.46529007",
"0.45922315",
"0.457492",
"0.4555513",
"0.45065725",
"0.4488905",
"0.4473739",
"0.44697726",
"0.44694299",
"0.44630593",
"0.44... | 0.76610595 | 1 |
Is json_grow a valid json representation of a species growth? | def is_valid_pop_grow(json_grow):
return isinstance(json_grow, list) and len(json_grow) == 3 and json_grow[0] == "population" and\
not isinstance(json_grow[1], bool) and isinstance(json_grow[1], int) and json_grow[1] >= 0 and\
not isinstance(json_grow[2], bool) and isinstance(json_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_grow_population(json_grow):\n if GrowPopulation.is_valid_pop_grow(json_grow):\n return GrowPopulation(json_grow[1], json_grow[2])\n else:\n raise Exception(\"Invalid json population grow action\")",
"def parse_proxy_grow_population(json_grow):\n if GrowPopulat... | [
"0.67845356",
"0.64108104",
"0.62416023",
"0.56160873",
"0.5391421",
"0.5343686",
"0.5216057",
"0.5167628",
"0.515412",
"0.5050066",
"0.5041063",
"0.5009137",
"0.49782172",
"0.49490848",
"0.49448678",
"0.4934982",
"0.49224684",
"0.4890417",
"0.4880887",
"0.48737907",
"0.48529... | 0.66377836 | 1 |
Returns a json interpretation of a grow population object | def to_json(self):
return ["population", self.species_index, self.card_trade_index] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_grow_population(json_grow):\n if GrowPopulation.is_valid_pop_grow(json_grow):\n return GrowPopulation(json_grow[1], json_grow[2])\n else:\n raise Exception(\"Invalid json population grow action\")",
"def as_json(self):\n # if we don't convert it to a dict we'l... | [
"0.6523305",
"0.6272748",
"0.6193445",
"0.6013572",
"0.60070646",
"0.600554",
"0.58979523",
"0.5883446",
"0.5804956",
"0.57915723",
"0.577272",
"0.5772612",
"0.57659566",
"0.5764919",
"0.56975114",
"0.5694334",
"0.5686872",
"0.5675293",
"0.5651329",
"0.5649477",
"0.5640382",
... | 0.7153903 | 0 |
Use svg formats to display things ploted | def use_svg_display():
display.set_matplotlib_formats('svg') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def use_svg_display(): #@save\n display.set_matplotlib_formats('svg')",
"def _repr_svg_(self):\n pass",
"def _repr_svg_(self):\n if not IPythonConsole.ipython_useSVG:\n return None\n mol = self.owner.mol\n keku = IPythonConsole.kekulizeStructures\n size = IPyth... | [
"0.8240741",
"0.80497175",
"0.7145356",
"0.7145356",
"0.7055136",
"0.68867075",
"0.6879458",
"0.6758306",
"0.6727566",
"0.6718365",
"0.6621455",
"0.6587107",
"0.6476702",
"0.64378935",
"0.6431482",
"0.6402853",
"0.63732785",
"0.62872374",
"0.6284717",
"0.6247871",
"0.62346727... | 0.80888575 | 1 |
Set the plot view size to figsize | def set_figsize(figsize=(3.5, 2.5)):
use_svg_display()
plt.rcParams['figure.figsize'] = figsize | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_figsize(figsize=(3.5, 2.5)): #@save\n use_svg_display()\n d2l.plt.rcParams['figure.figsize'] = figsize",
"def figure(figsize=None,xSize=3.5,ySize=3.5,dpi=600,kw_setup=dict(),**kw):\n plot_setup(**kw_setup)\n if (figsize is not None):\n xSize = figsize[0]\n ySize = figsize[1]\n ... | [
"0.78902227",
"0.6751782",
"0.6596949",
"0.65897006",
"0.65781975",
"0.6517747",
"0.6500645",
"0.64662874",
"0.6454464",
"0.64407265",
"0.63999575",
"0.63668054",
"0.6301865",
"0.6289062",
"0.6275893",
"0.62544805",
"0.6221664",
"0.6207713",
"0.61245376",
"0.6113087",
"0.6098... | 0.7844332 | 1 |
Plot some data images of FashionMnistDataset in one line with labels | def show_fashion_mnist(images, labels):
use_svg_display()
# the '_' here means we don't need that parameter
# here init a figure to plot images
_, figs = plt.subplots(1, len(images), figsize=(12, 12))
for f, img, lbl in zip(figs, images, labels):
# show the image
f.imshow(img.view(28... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_labels(lbl: scipy.ndarray, lbl_count: int) -> None:\n color_map = scipy.rand(lbl_count, 3)\n color_map = matplotlib.colors.ListedColormap(color_map)\n plt.imshow(lbl, cmap=color_map)\n plt.show()",
"def visualize(**images):\n n_images = len(images)\n plt.figure(figsize=(20,8))\n for... | [
"0.6728893",
"0.66888267",
"0.6639547",
"0.66114897",
"0.6588676",
"0.65629697",
"0.6526726",
"0.65079933",
"0.63961387",
"0.6348753",
"0.6331709",
"0.6322642",
"0.6306844",
"0.6306844",
"0.6306844",
"0.63059264",
"0.6299445",
"0.6282435",
"0.62814975",
"0.6277304",
"0.626990... | 0.73599213 | 0 |
plot the trace of 2d function's figure and results | def show_trace_2d(f, results):
plt.close()
# draw input points
plt.plot(*zip(*results), '-o', color='#ff7f0e')
# get the field of figure
x1, x2 = np.meshgrid(np.arange(-5.5, 1.0, 0.1), np.arange(-3.0, 1.0, 0.1))
# draw the contour of function using x1,x2 as step
plt.contour(x1, x2, f(x1, x2)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_trace_2d(f, results): #@save\n set_figsize()\n plt.plot(*zip(*results), '-o', color='#ff7f0e')\n x1, x2 = torch.meshgrid(torch.arange(-5.5, 1.0, 0.1),torch.arange(-3.0, 1.0, 0.1))\n plt.contour(x1, x2, f(x1, x2), colors='#1f77b4')\n plt.xlabel('x1')",
"def show_trace_2d(f, results): #@s... | [
"0.8243612",
"0.80253506",
"0.71199554",
"0.6722876",
"0.6595502",
"0.6406169",
"0.6404475",
"0.63895744",
"0.63739944",
"0.6362752",
"0.6319799",
"0.62973255",
"0.6270325",
"0.6204418",
"0.6188492",
"0.6185035",
"0.617978",
"0.6163521",
"0.61322105",
"0.61197263",
"0.6113812... | 0.820347 | 1 |
Transform bbox to rectangle which can be plot in a figure. | def bbox_to_rect(bbox, color):
return plt.Rectangle(
xy=(bbox[0], bbox[1]), width=bbox[2]-bbox[0], height=bbox[3]-bbox[1],
fill=False, edgecolor=color, linewidth=2
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vis_bbox(im, bbox):\n im = im[:, :, (2, 1, 0)]\n fig, ax = plt.subplots(figsize=(12, 12))\n ax.imshow(im, aspect='equal')\n ax.add_patch(\n plt.Rectangle((bbox[0], bbox[1]),\n bbox[2] - bbox[0],\n bbox[3] - bbox[1], fill=False,\n ... | [
"0.7295237",
"0.71999186",
"0.7162662",
"0.7128504",
"0.6923683",
"0.68880653",
"0.68832767",
"0.68619215",
"0.6833269",
"0.6768016",
"0.67155373",
"0.6684205",
"0.66383326",
"0.6633823",
"0.66184807",
"0.6602729",
"0.65662926",
"0.6528647",
"0.6516691",
"0.6504845",
"0.64721... | 0.8192315 | 0 |
Launch DagFileProcessorManager processor and start DAG parsing loop in manager. | def start(self) -> None:
context = self._get_multiprocessing_context()
self._last_parsing_stat_received_at = time.monotonic()
self._parent_signal_conn, child_signal_conn = context.Pipe()
process = context.Process(
target=type(self)._run_processor_manager,
args=(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start(self):\n self.register_exit_signals()\n\n set_new_process_group()\n\n self.log.info(\"Processing files using up to %s processes at a time \", self._parallelism)\n self.log.info(\"Process each file at most once every %s seconds\", self._file_process_interval)\n self.log.... | [
"0.6902342",
"0.59053934",
"0.5773313",
"0.55288255",
"0.54555",
"0.5432372",
"0.5419414",
"0.52692837",
"0.5262612",
"0.52342904",
"0.5214548",
"0.5171435",
"0.5146328",
"0.50828224",
"0.50824994",
"0.50663066",
"0.50369257",
"0.500083",
"0.4956117",
"0.49324197",
"0.4927846... | 0.77809423 | 0 |
Heartbeat DAG file processor and restart it if we are not done. | def _heartbeat_manager(self):
if not self._parent_signal_conn:
raise ValueError("Process not started.")
if self._process and not self._process.is_alive():
self._process.join(timeout=0)
if not self.done:
self.log.warning(
"DagFilePro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def startHeartbeat(self):\n self.post.__sendHeartbeat()",
"def _heartbeat_loop(self):\n # set last time so that \"if t_now - t_last >= HEARTBEAT_LOG_INTERVAL\"\n # below evalutes to True on the first run\n t_last = time.time() - HEARTBEAT_LOG_INTERVAL - 1\n while True:\n ... | [
"0.59002155",
"0.57033646",
"0.56694525",
"0.5598043",
"0.55476713",
"0.5539027",
"0.5517709",
"0.5490486",
"0.546607",
"0.5438334",
"0.5388866",
"0.5387239",
"0.5341168",
"0.53241",
"0.52901435",
"0.5288941",
"0.5280215",
"0.52654564",
"0.5257743",
"0.5253895",
"0.5241949",
... | 0.64968365 | 0 |
Sync metadata from stat queue and only keep the latest stat. | def _sync_metadata(self, stat):
self._done = stat.done
self._all_files_processed = stat.all_files_processed
self._last_parsing_stat_received_at = time.monotonic() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _push(self):\n if len(self._stat_now):\n self._stat_now['epoch_num'] = self.epoch_num\n self._stat_now['global_step'] = self.global_step\n\n self._stats.append(self._stat_now)\n self._stat_now = {}\n self._write_stat()",
"def sync() -> None:",
"... | [
"0.6097781",
"0.6036069",
"0.5823529",
"0.5772382",
"0.5762391",
"0.57144344",
"0.56363374",
"0.55983853",
"0.55737966",
"0.55737966",
"0.5540843",
"0.55382794",
"0.549456",
"0.5484625",
"0.5479431",
"0.5431175",
"0.5415981",
"0.54098845",
"0.5408363",
"0.54003614",
"0.539819... | 0.76762164 | 0 |
Whether the DagFileProcessorManager finished. | def done(self) -> bool:
return self._done | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def done(self):\n return self._is_done",
"def _is_done(self):\n pass",
"def done(self) -> bool:\n return pulumi.get(self, \"done\")",
"def finished(self):\n return self._state == FINISHED_STATE",
"def is_done(self):\n return self._done",
"def has_finished():",
"def is... | [
"0.717276",
"0.7171391",
"0.71180296",
"0.7105147",
"0.70777625",
"0.70586365",
"0.70552933",
"0.70439535",
"0.70309687",
"0.7009928",
"0.6952927",
"0.69490445",
"0.69233614",
"0.6890246",
"0.68833804",
"0.6863327",
"0.68570995",
"0.6841842",
"0.6841842",
"0.6841842",
"0.6837... | 0.72976714 | 0 |
Register signals that stop child processes. | def register_exit_signals(self):
signal.signal(signal.SIGINT, self._exit_gracefully)
signal.signal(signal.SIGTERM, self._exit_gracefully)
# So that we ignore the debug dump signal, making it easier to send
signal.signal(signal.SIGUSR2, signal.SIG_IGN) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kill_child_processes(parent_pid, sig=signal.SIGTERM):\n try:\n parent = psutil.Process(parent_pid)\n except psutil.NoSuchProcess:\n return\n children = parent.children(recursive=True)\n for process in children:\n try:\n process.send_signal(sig)\n except psutil... | [
"0.6800868",
"0.65543705",
"0.65473795",
"0.6545365",
"0.6469888",
"0.644261",
"0.62947786",
"0.6292127",
"0.621205",
"0.6175318",
"0.61510694",
"0.6035429",
"0.59871596",
"0.59867096",
"0.5972011",
"0.5968891",
"0.59670824",
"0.595869",
"0.5954736",
"0.5928941",
"0.5890723",... | 0.7050701 | 0 |
Scan at fix internal DAGs which are no longer present in files. | def _scan_stale_dags(self):
now = timezone.utcnow()
elapsed_time_since_refresh = (now - self.last_deactivate_stale_dags_time).total_seconds()
if elapsed_time_since_refresh > self.parsing_cleanup_interval:
last_parsed = {
fp: self.get_last_finish_time(fp) for fp in sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup_in_progress_bugs_without_patches(self):\n raise NotImplementedError(\"not yet done\")",
"def clean_condor(c):\n for fname in glob.glob(os.path.join(ROOT_DIR, '*.dag')):\n _delete_pattern(fname + '.*')\n for fname in glob.glob(os.path.join(ROOT_DIR, '*.sub')):\n temps = []\n... | [
"0.60389453",
"0.55653155",
"0.55171776",
"0.5486258",
"0.5453722",
"0.54526615",
"0.543999",
"0.54291993",
"0.5398894",
"0.5323134",
"0.531323",
"0.52942467",
"0.5255985",
"0.5253049",
"0.523504",
"0.5208834",
"0.5197419",
"0.51893747",
"0.51579833",
"0.51465344",
"0.5143649... | 0.5682571 | 1 |
Refresh file paths from dag dir if we haven't done it for too long. | def _refresh_dag_dir(self) -> bool:
now = timezone.utcnow()
elapsed_time_since_refresh = (now - self.last_dag_dir_refresh_time).total_seconds()
if elapsed_time_since_refresh > self.dag_dir_list_interval:
# Build up a list of Python files that could contain DAGs
self.log.i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh_all(self) -> None:\n self._update_thread.force_refresh_folder(self.feed_cache)",
"def _scan_stale_dags(self):\n now = timezone.utcnow()\n elapsed_time_since_refresh = (now - self.last_deactivate_stale_dags_time).total_seconds()\n if elapsed_time_since_refresh > self.parsin... | [
"0.61695445",
"0.6074694",
"0.599499",
"0.5934256",
"0.58923125",
"0.5880447",
"0.5830198",
"0.5736178",
"0.5667084",
"0.56275195",
"0.56197757",
"0.5597608",
"0.55753165",
"0.5571855",
"0.55354047",
"0.5500853",
"0.54532933",
"0.5401339",
"0.5387552",
"0.53727967",
"0.536421... | 0.79090995 | 0 |
Occasionally print out stats about how fast the files are getting processed. | def _print_stat(self):
if 0 < self.print_stats_interval < time.monotonic() - self.last_stat_print_time:
if self._file_paths:
self._log_file_processing_stats(self._file_paths)
self.last_stat_print_time = time.monotonic() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_stats_thread(root):\n start = time.time()\n\n while True:\n time.sleep(3)\n timenow = time.time()\n elapsed = str(timedelta(seconds = timenow - start))\n inodesps = inodecount[root] / (timenow - start)\n logger.info('CRAWL STATS (path {0}, files {1}, dirs {2}, elaps... | [
"0.6778385",
"0.66478163",
"0.6588825",
"0.6544332",
"0.649206",
"0.6388902",
"0.63528067",
"0.62239826",
"0.62017673",
"0.6104883",
"0.6089805",
"0.6086532",
"0.60859054",
"0.606557",
"0.6016941",
"0.59960234",
"0.5962753",
"0.5934713",
"0.59274864",
"0.5912956",
"0.589714",... | 0.6904008 | 0 |
Clear import errors for files that no longer exist. | def clear_nonexistent_import_errors(file_paths: list[str] | None, session=NEW_SESSION):
query = session.query(errors.ImportError)
if file_paths:
query = query.filter(~errors.ImportError.filename.in_(file_paths))
query.delete(synchronize_session="fetch")
session.commit() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_errors(self) -> None:",
"def clear_errors(self) -> None:",
"def test_dupe_imports(self):\r\n good_file = self._get_del_file()\r\n imp = Importer(good_file, username=u\"admin\")\r\n imp.process()\r\n\r\n good_file = self._get_del_file()\r\n imp = Importer(good_file, ... | [
"0.6780713",
"0.6780713",
"0.6319068",
"0.625522",
"0.6212573",
"0.6209276",
"0.61864525",
"0.613826",
"0.6076129",
"0.6056241",
"0.6041389",
"0.59878427",
"0.59337693",
"0.5921071",
"0.5900005",
"0.5886828",
"0.5866447",
"0.5844186",
"0.58224547",
"0.5803731",
"0.58004135",
... | 0.7748205 | 0 |
Retrieve the PID of the process processing the given file or None if the file is not being processed. | def get_pid(self, file_path) -> int | None:
if file_path in self._processors:
return self._processors[file_path].pid
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPid(self):\n try:\n fh = open(self.filename)\n except OSError:\n return None\n line = fh.readline()\n try:\n return string.atoi(line) # trailing newline doesn't matter\n except ValueError:\n return None",
"def get_pid(self):\n... | [
"0.8067979",
"0.74126506",
"0.7294264",
"0.72064096",
"0.7060661",
"0.70579207",
"0.70573556",
"0.6864191",
"0.68129",
"0.6786206",
"0.6730113",
"0.6702546",
"0.66658545",
"0.6574954",
"0.64804435",
"0.64639413",
"0.6415075",
"0.6396912",
"0.6365991",
"0.62697995",
"0.6260199... | 0.8661299 | 0 |
Retrieve the last processing time of a specific path. | def get_last_runtime(self, file_path) -> float | None:
stat = self._file_stats.get(file_path)
return stat.last_duration.total_seconds() if stat and stat.last_duration else None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_last_finish_time(self, file_path) -> datetime | None:\n stat = self._file_stats.get(file_path)\n return stat.last_finish_time if stat else None",
"def last_access_time(path):\r\n return os.stat(path)[stat.ST_ATIME]",
"def get_mtime(path):\n try:\n return path.... | [
"0.7153084",
"0.7028886",
"0.6791224",
"0.66785485",
"0.6607391",
"0.65836203",
"0.6493155",
"0.6441159",
"0.6370403",
"0.63642323",
"0.6360754",
"0.63283616",
"0.6318243",
"0.6314464",
"0.627511",
"0.62685287",
"0.6256992",
"0.62244946",
"0.62165654",
"0.61994123",
"0.617312... | 0.72417444 | 0 |
Retrieve the total number of errors from processing a specific path. | def get_last_error_count(self, file_path) -> int | None:
stat = self._file_stats.get(file_path)
return stat.import_errors if stat else None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_count(self):\n return len(self.errors)",
"def total_errors(self):\r\n\r\n child_errors = sum(len(tree) for _, tree in iteritems(self._contents))\r\n return len(self.errors) + child_errors",
"def get_error_count(self):\n return sum(1 for outcome in (r.outcome for r in self.... | [
"0.68291694",
"0.66321224",
"0.6539631",
"0.65059227",
"0.6414099",
"0.62368226",
"0.62356204",
"0.62267065",
"0.6063823",
"0.6063233",
"0.6059517",
"0.6041053",
"0.60339576",
"0.6027389",
"0.6023086",
"0.6006854",
"0.59940124",
"0.59850127",
"0.5966939",
"0.5951586",
"0.5920... | 0.6987642 | 0 |
Retrieve the last completion time for processing a specific path. | def get_last_finish_time(self, file_path) -> datetime | None:
stat = self._file_stats.get(file_path)
return stat.last_finish_time if stat else None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_completion_time(self) -> float:\n return self._last_completion_time - self._start_time",
"def completion_time(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"completion_time\")",
"def completion_time(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self,... | [
"0.71924007",
"0.71125346",
"0.71125346",
"0.68504256",
"0.6718735",
"0.66397405",
"0.6231912",
"0.6220517",
"0.621313",
"0.6198457",
"0.6186671",
"0.6135579",
"0.61289394",
"0.6083259",
"0.6079001",
"0.60781735",
"0.6078041",
"0.6074305",
"0.6071143",
"0.6070091",
"0.6058746... | 0.73683923 | 0 |
Retrieve the last start time for processing a specific path. | def get_start_time(self, file_path) -> datetime | None:
if file_path in self._processors:
return self._processors[file_path].start_time
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_starttime(self):\n filetime = datetime.datetime.strptime(self.filenametime,\n \"%Y%m%d_%H%M%S\")\n if self.ldat_type != 'acc':\n starttime = filetime\n else:\n starttime = filetime - datetime.timedelta(seconds=512)\n ... | [
"0.7114907",
"0.6834792",
"0.67970824",
"0.67896086",
"0.6649942",
"0.658254",
"0.65279",
"0.650036",
"0.6494617",
"0.6490718",
"0.6469819",
"0.64607596",
"0.6422892",
"0.6396065",
"0.6393572",
"0.638003",
"0.6376569",
"0.6376569",
"0.63747007",
"0.6368677",
"0.6352756",
"0... | 0.71356505 | 0 |
Return the number of times the given file has been parsed. | def get_run_count(self, file_path) -> int:
stat = self._file_stats.get(file_path)
return stat.run_count if stat else 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_count(file):\n with open(file, \"r\") as f:\n return sum(1 for line in f)",
"def total_number():\r\n total_number = 0\r\n file_read = read_file()\r\n for key in file_read:\r\n total_number = total_number + len(file_read[key])\r\n return total_number",
"def fileCounter(dire... | [
"0.71401644",
"0.69211084",
"0.6917881",
"0.6879534",
"0.68474394",
"0.6822997",
"0.6816414",
"0.68026906",
"0.68026906",
"0.67917204",
"0.6774328",
"0.67685753",
"0.6762162",
"0.67529136",
"0.6736762",
"0.6731634",
"0.67200154",
"0.6715869",
"0.6663942",
"0.6640681",
"0.6634... | 0.7443984 | 0 |
Return the dag_director as a string. | def get_dag_directory(self) -> str:
if isinstance(self._dag_directory, Path):
return str(self._dag_directory.resolve())
else:
return str(self._dag_directory) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n target = self.signal_target\n if target is None:\n target = self.signal_filter.__name__\n return \"Synapse(%s <-> %s)\" % (self.organ_id, target)",
"def dag_name(self):\n return self._dag_name",
"def __str__(self):\n\t\treturn str(self.graph)",
"def... | [
"0.6590569",
"0.62509996",
"0.6173706",
"0.6095808",
"0.60756105",
"0.60463786",
"0.6001741",
"0.5846653",
"0.58369434",
"0.5813847",
"0.5797878",
"0.5797136",
"0.5790996",
"0.57783884",
"0.57694286",
"0.5727002",
"0.5662419",
"0.5660866",
"0.5648074",
"0.5633061",
"0.5629607... | 0.6324174 | 1 |
Sleeps until all the processors are done. | def wait_until_finished(self):
for processor in self._processors.values():
while not processor.done:
time.sleep(0.1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_all_process_done(self) -> None:\n while len(self.process_queue) > 0:\n self.check_process_done()",
"def wait_threads(self):\n\n self.queue.join()",
"def wait_forever(self):\r\n while True:\r\n time.sleep(0.5)",
"def wait(self):\n time.sleep(self.next())",
"d... | [
"0.6963551",
"0.6772784",
"0.6609773",
"0.66002274",
"0.6512814",
"0.6456526",
"0.63595754",
"0.6347221",
"0.63418",
"0.6324502",
"0.6324502",
"0.6324502",
"0.6324502",
"0.6324502",
"0.6324502",
"0.6324502",
"0.6324502",
"0.6324502",
"0.63123554",
"0.6303206",
"0.62664676",
... | 0.80391806 | 0 |
Collect the result from any finished DAG processors. | def collect_results(self) -> None:
ready = multiprocessing.connection.wait(
self.waitables.keys() - [self._direct_scheduler_conn], timeout=0
)
for sentinel in ready:
if sentinel is self._direct_scheduler_conn:
continue
processor = cast(DagFile... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_results(self):\n return self._do_action_under_lock(self._process_results)",
"def process(self, results):\n raise NotImplementedError",
"def collect(self):\n pass",
"def collect(self):\n if self._completion_status is None or not self._completion_status.done:\n ... | [
"0.65392697",
"0.6166918",
"0.6131396",
"0.61133945",
"0.6108954",
"0.6090083",
"0.60769624",
"0.60753834",
"0.6058896",
"0.6058896",
"0.6026497",
"0.60222393",
"0.59910214",
"0.59865344",
"0.59636956",
"0.5914493",
"0.5898774",
"0.5867254",
"0.58663267",
"0.5846436",
"0.5846... | 0.7560404 | 0 |
Start more processors if we have enough slots and files to process. | def start_new_processes(self):
# initialize cache to mutualize calls to Variable.get in DAGs
# needs to be done before this process is forked to create the DAG parsing processes.
SecretCache.init()
while self._parallelism - len(self._processors) > 0 and self._file_path_queue:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schdule(self):\n while self.queue:\n if self.processing >= self.maxProcessing:\n # We have reached the maximum number of parallel\n # tasks.\n break\n\n item, completeDeferred = self.queue.pop(0)\n\n self.processing += 1 ... | [
"0.58189386",
"0.5582102",
"0.55208045",
"0.5505154",
"0.54729325",
"0.5429797",
"0.53998035",
"0.53761727",
"0.53390145",
"0.53227335",
"0.53051144",
"0.52963483",
"0.52729404",
"0.5251894",
"0.5228932",
"0.51991844",
"0.5195823",
"0.5165046",
"0.5165046",
"0.51534986",
"0.5... | 0.58833116 | 0 |
Kill any file processors that timeout to defend against process hangs. | def _kill_timed_out_processors(self):
now = timezone.utcnow()
processors_to_remove = []
for file_path, processor in self._processors.items():
duration = now - processor.start_time
if duration > self._processor_timeout:
self.log.error(
"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self):\n for tmp_file in filter(lambda x: x.exists(), self.temp_files):\n tmp_file.unlink()\n\n for proc in self.processes:\n try:\n os.kill(proc, signal.SIGTERM)\n except ProcessLookupError:\n pass",
"def _AbortJoin(self, ... | [
"0.64615154",
"0.63152456",
"0.62957335",
"0.60748655",
"0.6066558",
"0.60211766",
"0.5990371",
"0.5971625",
"0.5948777",
"0.5891773",
"0.58864486",
"0.5882023",
"0.58638203",
"0.5838313",
"0.577172",
"0.5762323",
"0.5740598",
"0.57361495",
"0.5653952",
"0.564816",
"0.5636479... | 0.816324 | 0 |
Add stuff to the back or front of the file queue, unless it's already present. | def _add_paths_to_queue(self, file_paths_to_enqueue: list[str], add_at_front: bool):
new_file_paths = list(p for p in file_paths_to_enqueue if p not in self._file_path_queue)
if add_at_front:
self._file_path_queue.extendleft(new_file_paths)
else:
self._file_path_queue.ext... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enqueue_front(self, item):\n self._items.insert(0, item)",
"def bypass_queue(self, name):\n # self.queue = [name] + self.queue\n # self.queue.insert(0, name)\n\n # self.lst = [name] + self.lst # This person is brought to the front of the queue\n self.lst.insert(0, name) #N... | [
"0.63460886",
"0.6313469",
"0.6261927",
"0.6121886",
"0.60842025",
"0.60755575",
"0.6025526",
"0.600535",
"0.59981894",
"0.5954292",
"0.5923852",
"0.59160674",
"0.59160674",
"0.59157324",
"0.5904151",
"0.5899629",
"0.58940136",
"0.5866215",
"0.58652383",
"0.58476686",
"0.5843... | 0.65448594 | 0 |
Stop all running processors. | def terminate(self):
for processor in self._processors.values():
Stats.decr(
"dag_processing.processes", tags={"file_path": processor.file_path, "action": "terminate"}
)
processor.terminate() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop(self):\n for process in self.process:\n process.stop()",
"def stop_all():\n\twhile _running:\n\t\t_running[0].stop(noerror=True)",
"def stop_all_instances(self):\n print '# Stopping all the instances'\n number = self.compute.stop_all_instances()\n print '%d insta... | [
"0.8106002",
"0.77567285",
"0.7552621",
"0.75202745",
"0.7439674",
"0.7399022",
"0.7375506",
"0.7342175",
"0.733424",
"0.73039013",
"0.7276026",
"0.7195019",
"0.7175661",
"0.7161969",
"0.7149045",
"0.7115749",
"0.7114294",
"0.70981437",
"0.70830184",
"0.70610476",
"0.7045887"... | 0.7778282 | 1 |
Emit metrics about dag parsing summary. This is called once every time around the parsing "loop" i.e. after all files have been parsed. | def emit_metrics(self):
parse_time = time.perf_counter() - self._parsing_start_time
Stats.gauge("dag_processing.total_parse_time", parse_time)
Stats.gauge("dagbag_size", sum(stat.num_dags for stat in self._file_stats.values()))
Stats.gauge(
"dag_processing.import_errors", sum... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _log_file_processing_stats(self, known_file_paths):\n # File Path: Path to the file containing the DAG definition\n # PID: PID associated with the process that's processing the file. May\n # be empty.\n # Runtime: If the process is currently running, how long it's been\n # ru... | [
"0.6030052",
"0.56780493",
"0.5605528",
"0.549664",
"0.5452645",
"0.5409617",
"0.5409617",
"0.5368399",
"0.53507394",
"0.5329125",
"0.53232145",
"0.5293525",
"0.52526665",
"0.5219868",
"0.5217269",
"0.52124816",
"0.5212287",
"0.52016246",
"0.5195992",
"0.51884717",
"0.5188069... | 0.8361473 | 0 |
Creates a new saved home | def save_new_home(user_id, rm_property_id, longitude, latitude, address):
home = SavedHomes(
user_id = user_id,
rm_property_id = rm_property_id,
longitude=longitude,
latitude=latitude,
address=address,
)
db.session.add(home)
db.session.commit()
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_home():\n meta_desc = (\n 'Expected values and probability per lap of step-up'\n ' banners in Final Fantasy Brave Exvius (FFBE)')\n template_vars = {\n 'title' : sitesettings.SITE_NAME,\n 'siteurl' : sitesettings.SITE_URL,\n 'sitename' : sitesettings.SITE_NAME,\n... | [
"0.6463083",
"0.6199926",
"0.6192472",
"0.60189664",
"0.60189664",
"0.5912727",
"0.5791303",
"0.5774873",
"0.57226336",
"0.5657594",
"0.5638584",
"0.56131387",
"0.5612833",
"0.56073946",
"0.5592318",
"0.5582505",
"0.5559216",
"0.55544263",
"0.55526763",
"0.55526763",
"0.55003... | 0.7197667 | 0 |
Creates a new home note on saved home | def create_home_note(body,saved_home_id):
note = HomeNotes(body=body, created_at = date.today(), saved_home_id=saved_home_id)
db.session.add(note)
db.session.commit()
return note | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_note(self, noteTitle, note, date):\n user = User.objects.create(username='userdemo')\n user.set_password('calnote24')\n user.save()\n Note.objects.create(noteTitle=noteTitle, note=note, date=date, user_id=user.id)",
"def createNote(self, authenticationToken, note):\r\n p... | [
"0.6835227",
"0.6575961",
"0.6395481",
"0.63940823",
"0.6325117",
"0.6285266",
"0.6280023",
"0.6272395",
"0.62301695",
"0.6170147",
"0.61274177",
"0.61244637",
"0.5765972",
"0.5762432",
"0.5730444",
"0.57291615",
"0.57194144",
"0.5715769",
"0.5715107",
"0.5631282",
"0.5622855... | 0.829951 | 0 |
removes note on saved home | def remove_home_note(home_note_id):
note = HomeNotes.query.filter_by(home_note_id=home_note_id).first()
db.session.delete(note)
db.session.commit()
return note | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rm(ctx, note):\n directory = ctx.obj[\"config\"][\"owner\"][\"dir\"]\n note = Note(directory, note)\n os.remove(note.path)\n\n click.secho(\"Success! Removed {}\".format(note.filename), fg=\"green\")",
"def remove_note(self, note: int) -> None:\n if note in self.notes:\n self.no... | [
"0.7145103",
"0.6710412",
"0.65346456",
"0.635698",
"0.6318039",
"0.62572455",
"0.62466663",
"0.62466663",
"0.62466663",
"0.6242504",
"0.62359774",
"0.62215626",
"0.61557317",
"0.6136657",
"0.609395",
"0.6005389",
"0.5947361",
"0.5940694",
"0.59406656",
"0.5910344",
"0.590066... | 0.7018293 | 1 |
queries SavedHomes using saved_home_id to get longitude | def saved_home_longitude(saved_home_id):
sql = "SELECT longitude FROM saved_homes WHERE saved_home_id = :saved_home_id"
cursor = db.session.execute(sql,{"saved_home_id": saved_home_id})
longitude = cursor.fetchone()
return longitude | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saved_home_latitude(saved_home_id):\n\n sql = \"SELECT latitude FROM saved_homes WHERE saved_home_id = :saved_home_id\"\n\n cursor = db.session.execute(sql,{\"saved_home_id\": saved_home_id})\n\n latitude = cursor.fetchone()\n\n return latitude",
"def get_address(saved_home_id):\n\n sql = \"SE... | [
"0.76033956",
"0.6118254",
"0.5742464",
"0.57084286",
"0.57080907",
"0.5699466",
"0.551681",
"0.55092907",
"0.54990584",
"0.5489118",
"0.5447527",
"0.54141396",
"0.54135525",
"0.5385749",
"0.52658933",
"0.526368",
"0.52612764",
"0.5260204",
"0.5239613",
"0.5237394",
"0.522457... | 0.7990343 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.