Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
IRobotEntity.on_message | (self, json_data) | Update state on message change. | Update state on message change. | def on_message(self, json_data):
"""Update state on message change."""
state = json_data.get("state", {}).get("reported", {})
if self.new_state_filter(state):
self.schedule_update_ha_state() | [
"def",
"on_message",
"(",
"self",
",",
"json_data",
")",
":",
"state",
"=",
"json_data",
".",
"get",
"(",
"\"state\"",
",",
"{",
"}",
")",
".",
"get",
"(",
"\"reported\"",
",",
"{",
"}",
")",
"if",
"self",
".",
"new_state_filter",
"(",
"state",
")",
... | [
128,
4
] | [
132,
43
] | python | en | ['en', 'en', 'en'] | True |
IRobotVacuum.__init__ | (self, roomba, blid) | Initialize the iRobot handler. | Initialize the iRobot handler. | def __init__(self, roomba, blid):
"""Initialize the iRobot handler."""
super().__init__(roomba, blid)
self._cap_position = self.vacuum_state.get("cap", {}).get("pose") == 1 | [
"def",
"__init__",
"(",
"self",
",",
"roomba",
",",
"blid",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"roomba",
",",
"blid",
")",
"self",
".",
"_cap_position",
"=",
"self",
".",
"vacuum_state",
".",
"get",
"(",
"\"cap\"",
",",
"{",
"}",
")... | [
138,
4
] | [
141,
78
] | python | en | ['en', 'lb', 'en'] | True |
IRobotVacuum.supported_features | (self) | Flag vacuum cleaner robot features that are supported. | Flag vacuum cleaner robot features that are supported. | def supported_features(self):
"""Flag vacuum cleaner robot features that are supported."""
return SUPPORT_IROBOT | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_IROBOT"
] | [
144,
4
] | [
146,
29
] | python | en | ['en', 'en', 'en'] | True |
IRobotVacuum.battery_level | (self) | Return the battery level of the vacuum cleaner. | Return the battery level of the vacuum cleaner. | def battery_level(self):
"""Return the battery level of the vacuum cleaner."""
return self._battery_level | [
"def",
"battery_level",
"(",
"self",
")",
":",
"return",
"self",
".",
"_battery_level"
] | [
149,
4
] | [
151,
34
] | python | en | ['en', 'en', 'en'] | True |
IRobotVacuum.state | (self) | Return the state of the vacuum cleaner. | Return the state of the vacuum cleaner. | def state(self):
"""Return the state of the vacuum cleaner."""
return self._robot_state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_robot_state"
] | [
154,
4
] | [
156,
32
] | python | en | ['en', 'en', 'en'] | True |
IRobotVacuum.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self) -> bool:
"""Return True if entity is available."""
return True | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"True"
] | [
159,
4
] | [
161,
19
] | python | en | ['en', 'en', 'en'] | True |
IRobotVacuum.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
164,
4
] | [
166,
25
] | python | en | ['en', 'en', 'en'] | True |
IRobotVacuum.device_state_attributes | (self) | Return the state attributes of the device. | Return the state attributes of the device. | def device_state_attributes(self):
"""Return the state attributes of the device."""
state = self.vacuum_state
# Roomba software version
software_version = state.get("softwareVer")
# Set properties that are to appear in the GUI
state_attrs = {ATTR_SOFTWARE_VERSION: softw... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"state",
"=",
"self",
".",
"vacuum_state",
"# Roomba software version",
"software_version",
"=",
"state",
".",
"get",
"(",
"\"softwareVer\"",
")",
"# Set properties that are to appear in the GUI",
"state_attrs",
"="... | [
169,
4
] | [
212,
26
] | python | en | ['en', 'en', 'en'] | True |
IRobotVacuum.on_message | (self, json_data) | Update state on message change. | Update state on message change. | def on_message(self, json_data):
"""Update state on message change."""
state = json_data.get("state", {}).get("reported", {})
if self.new_state_filter(state):
_LOGGER.debug("Got new state from the vacuum: %s", json_data)
self.schedule_update_ha_state() | [
"def",
"on_message",
"(",
"self",
",",
"json_data",
")",
":",
"state",
"=",
"json_data",
".",
"get",
"(",
"\"state\"",
",",
"{",
"}",
")",
".",
"get",
"(",
"\"reported\"",
",",
"{",
"}",
")",
"if",
"self",
".",
"new_state_filter",
"(",
"state",
")",
... | [
214,
4
] | [
219,
43
] | python | en | ['en', 'en', 'en'] | True |
IRobotVacuum.async_start | (self) | Start or resume the cleaning task. | Start or resume the cleaning task. | async def async_start(self):
"""Start or resume the cleaning task."""
if self.state == STATE_PAUSED:
await self.hass.async_add_executor_job(self.vacuum.send_command, "resume")
else:
await self.hass.async_add_executor_job(self.vacuum.send_command, "start") | [
"async",
"def",
"async_start",
"(",
"self",
")",
":",
"if",
"self",
".",
"state",
"==",
"STATE_PAUSED",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"vacuum",
".",
"send_command",
",",
"\"resume\"",
")",
"else",
":",
... | [
221,
4
] | [
226,
85
] | python | en | ['en', 'en', 'en'] | True |
IRobotVacuum.async_stop | (self, **kwargs) | Stop the vacuum cleaner. | Stop the vacuum cleaner. | async def async_stop(self, **kwargs):
"""Stop the vacuum cleaner."""
await self.hass.async_add_executor_job(self.vacuum.send_command, "stop") | [
"async",
"def",
"async_stop",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"vacuum",
".",
"send_command",
",",
"\"stop\"",
")"
] | [
228,
4
] | [
230,
80
] | python | en | ['en', 'en', 'en'] | True |
IRobotVacuum.async_pause | (self) | Pause the cleaning cycle. | Pause the cleaning cycle. | async def async_pause(self):
"""Pause the cleaning cycle."""
await self.hass.async_add_executor_job(self.vacuum.send_command, "pause") | [
"async",
"def",
"async_pause",
"(",
"self",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"vacuum",
".",
"send_command",
",",
"\"pause\"",
")"
] | [
232,
4
] | [
234,
81
] | python | en | ['en', 'en', 'en'] | True |
IRobotVacuum.async_return_to_base | (self, **kwargs) | Set the vacuum cleaner to return to the dock. | Set the vacuum cleaner to return to the dock. | async def async_return_to_base(self, **kwargs):
"""Set the vacuum cleaner to return to the dock."""
if self.state == STATE_CLEANING:
await self.async_pause()
for _ in range(0, 10):
if self.state == STATE_PAUSED:
break
await asyn... | [
"async",
"def",
"async_return_to_base",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"state",
"==",
"STATE_CLEANING",
":",
"await",
"self",
".",
"async_pause",
"(",
")",
"for",
"_",
"in",
"range",
"(",
"0",
",",
"10",
")",
":",
... | [
236,
4
] | [
244,
80
] | python | en | ['en', 'en', 'en'] | True |
IRobotVacuum.async_locate | (self, **kwargs) | Located vacuum. | Located vacuum. | async def async_locate(self, **kwargs):
"""Located vacuum."""
await self.hass.async_add_executor_job(self.vacuum.send_command, "find") | [
"async",
"def",
"async_locate",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"vacuum",
".",
"send_command",
",",
"\"find\"",
")"
] | [
246,
4
] | [
248,
80
] | python | en | ['en', 'la', 'en'] | False |
IRobotVacuum.async_send_command | (self, command, params=None, **kwargs) | Send raw command. | Send raw command. | async def async_send_command(self, command, params=None, **kwargs):
"""Send raw command."""
_LOGGER.debug("async_send_command %s (%s), %s", command, params, kwargs)
await self.hass.async_add_executor_job(
self.vacuum.send_command, command, params
) | [
"async",
"def",
"async_send_command",
"(",
"self",
",",
"command",
",",
"params",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"async_send_command %s (%s), %s\"",
",",
"command",
",",
"params",
",",
"kwargs",
")",
"await",
... | [
250,
4
] | [
255,
9
] | python | en | ['en', 'zh', 'en'] | True |
get_align_matrix | (aligned_ids, sparse=False, device=None, dtype=torch.float32) |
Get aligned matrix for feature alignment in sentence embedding
:param aligned_ids: list, aligned_ids[k] means original index of k-th token
:param sparse: whether to return sparse matrix
:param device: device of returned align matrix
:param dtype: dtype of returned align matrix
:return: align_ma... |
Get aligned matrix for feature alignment in sentence embedding
:param aligned_ids: list, aligned_ids[k] means original index of k-th token
:param sparse: whether to return sparse matrix
:param device: device of returned align matrix
:param dtype: dtype of returned align matrix
:return: align_ma... | def get_align_matrix(aligned_ids, sparse=False, device=None, dtype=torch.float32):
"""
Get aligned matrix for feature alignment in sentence embedding
:param aligned_ids: list, aligned_ids[k] means original index of k-th token
:param sparse: whether to return sparse matrix
:param device: device of re... | [
"def",
"get_align_matrix",
"(",
"aligned_ids",
",",
"sparse",
"=",
"False",
",",
"device",
"=",
"None",
",",
"dtype",
"=",
"torch",
".",
"float32",
")",
":",
"l0",
"=",
"max",
"(",
"aligned_ids",
")",
"+",
"1",
"l1",
"=",
"len",
"(",
"aligned_ids",
"... | [
4,
0
] | [
30,
23
] | python | en | ['en', 'error', 'th'] | False |
get_all_ngrams | (words) |
Get all n-grams of words
:param words: list of str
:return: ngrams, list of (list of str)
|
Get all n-grams of words
:param words: list of str
:return: ngrams, list of (list of str)
| def get_all_ngrams(words):
"""
Get all n-grams of words
:param words: list of str
:return: ngrams, list of (list of str)
"""
ngrams = []
N = len(words)
for n in range(1, N + 1):
for i in range(0, N - n + 1):
ngrams.append([words[j] for j in range(i, i + n)])
retu... | [
"def",
"get_all_ngrams",
"(",
"words",
")",
":",
"ngrams",
"=",
"[",
"]",
"N",
"=",
"len",
"(",
"words",
")",
"for",
"n",
"in",
"range",
"(",
"1",
",",
"N",
"+",
"1",
")",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"N",
"-",
"n",
"+",
... | [
33,
0
] | [
45,
17
] | python | en | ['en', 'error', 'th'] | False |
random_word_with_token_ids | (token_ids, tokenizer) |
Masking some random tokens for Language Model task with probabilities as in the original BERT paper.
:param token_ids: list of int, list of token id.
:param tokenizer: Tokenizer, object used for tokenization (we need it's vocab here)
:return: (list of str, list of int), masked tokens and related labels... |
Masking some random tokens for Language Model task with probabilities as in the original BERT paper.
:param token_ids: list of int, list of token id.
:param tokenizer: Tokenizer, object used for tokenization (we need it's vocab here)
:return: (list of str, list of int), masked tokens and related labels... | def random_word_with_token_ids(token_ids, tokenizer):
"""
Masking some random tokens for Language Model task with probabilities as in the original BERT paper.
:param token_ids: list of int, list of token id.
:param tokenizer: Tokenizer, object used for tokenization (we need it's vocab here)
:return:... | [
"def",
"random_word_with_token_ids",
"(",
"token_ids",
",",
"tokenizer",
")",
":",
"output_label",
"=",
"[",
"]",
"mask_id",
"=",
"tokenizer",
".",
"convert_tokens_to_ids",
"(",
"[",
"'[MASK]'",
"]",
")",
"[",
"0",
"]",
"for",
"i",
",",
"token_id",
"in",
"... | [
48,
0
] | [
80,
34
] | python | en | ['en', 'error', 'th'] | False |
async_setup_platform | (hass, config) | Set up the Telegram polling platform. | Set up the Telegram polling platform. | async def async_setup_platform(hass, config):
"""Set up the Telegram polling platform."""
bot = initialize_bot(config)
pol = TelegramPoll(bot, hass, config[CONF_ALLOWED_CHAT_IDS])
@callback
def _start_bot(_event):
"""Start the bot."""
pol.start_polling()
@callback
def _stop... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
")",
":",
"bot",
"=",
"initialize_bot",
"(",
"config",
")",
"pol",
"=",
"TelegramPoll",
"(",
"bot",
",",
"hass",
",",
"config",
"[",
"CONF_ALLOWED_CHAT_IDS",
"]",
")",
"@",
"callback",
"de... | [
15,
0
] | [
33,
15
] | python | en | ['en', 'da', 'en'] | True |
process_error | (bot, update, error) | Telegram bot error handler. | Telegram bot error handler. | def process_error(bot, update, error):
"""Telegram bot error handler."""
try:
raise error
except (TimedOut, NetworkError, RetryAfter):
# Long polling timeout or connection problem. Nothing serious.
pass
except TelegramError:
_LOGGER.error('Update "%s" caused error "%s"', ... | [
"def",
"process_error",
"(",
"bot",
",",
"update",
",",
"error",
")",
":",
"try",
":",
"raise",
"error",
"except",
"(",
"TimedOut",
",",
"NetworkError",
",",
"RetryAfter",
")",
":",
"# Long polling timeout or connection problem. Nothing serious.",
"pass",
"except",
... | [
36,
0
] | [
44,
69
] | python | da | ['da', 'no', 'en'] | False |
message_handler | (handler) | Create messages handler. | Create messages handler. | def message_handler(handler):
"""Create messages handler."""
class MessageHandler(Handler):
"""Telegram bot message handler."""
def __init__(self):
"""Initialize the messages handler instance."""
super().__init__(handler)
def check_update(self, update):
... | [
"def",
"message_handler",
"(",
"handler",
")",
":",
"class",
"MessageHandler",
"(",
"Handler",
")",
":",
"\"\"\"Telegram bot message handler.\"\"\"",
"def",
"__init__",
"(",
"self",
")",
":",
"\"\"\"Initialize the messages handler instance.\"\"\"",
"super",
"(",
")",
".... | [
47,
0
] | [
66,
27
] | python | en | ['en', 'lb', 'en'] | True |
TelegramPoll.__init__ | (self, bot, hass, allowed_chat_ids) | Initialize the polling instance. | Initialize the polling instance. | def __init__(self, bot, hass, allowed_chat_ids):
"""Initialize the polling instance."""
BaseTelegramBotEntity.__init__(self, hass, allowed_chat_ids)
self.updater = Updater(bot=bot, workers=4)
self.dispatcher = self.updater.dispatcher
self.dispatcher.add_handler(message_handler... | [
"def",
"__init__",
"(",
"self",
",",
"bot",
",",
"hass",
",",
"allowed_chat_ids",
")",
":",
"BaseTelegramBotEntity",
".",
"__init__",
"(",
"self",
",",
"hass",
",",
"allowed_chat_ids",
")",
"self",
".",
"updater",
"=",
"Updater",
"(",
"bot",
"=",
"bot",
... | [
72,
4
] | [
81,
56
] | python | en | ['en', 'en', 'en'] | True |
TelegramPoll.start_polling | (self) | Start the polling task. | Start the polling task. | def start_polling(self):
"""Start the polling task."""
self.updater.start_polling() | [
"def",
"start_polling",
"(",
"self",
")",
":",
"self",
".",
"updater",
".",
"start_polling",
"(",
")"
] | [
83,
4
] | [
85,
36
] | python | en | ['en', 'no', 'en'] | True |
TelegramPoll.stop_polling | (self) | Stop the polling task. | Stop the polling task. | def stop_polling(self):
"""Stop the polling task."""
self.updater.stop() | [
"def",
"stop_polling",
"(",
"self",
")",
":",
"self",
".",
"updater",
".",
"stop",
"(",
")"
] | [
87,
4
] | [
89,
27
] | python | en | ['en', 'en', 'en'] | True |
TelegramPoll.process_update | (self, bot, update) | Process incoming message. | Process incoming message. | def process_update(self, bot, update):
"""Process incoming message."""
self.process_message(update.to_dict()) | [
"def",
"process_update",
"(",
"self",
",",
"bot",
",",
"update",
")",
":",
"self",
".",
"process_message",
"(",
"update",
".",
"to_dict",
"(",
")",
")"
] | [
91,
4
] | [
93,
46
] | python | en | ['en', 'en', 'en'] | True |
FluNearYouFlowHandler.data_schema | (self) | Return the data schema for integration. | Return the data schema for integration. | def data_schema(self):
"""Return the data schema for integration."""
return vol.Schema(
{
vol.Required(
CONF_LATITUDE, default=self.hass.config.latitude
): cv.latitude,
vol.Required(
CONF_LONGITUDE, defau... | [
"def",
"data_schema",
"(",
"self",
")",
":",
"return",
"vol",
".",
"Schema",
"(",
"{",
"vol",
".",
"Required",
"(",
"CONF_LATITUDE",
",",
"default",
"=",
"self",
".",
"hass",
".",
"config",
".",
"latitude",
")",
":",
"cv",
".",
"latitude",
",",
"vol"... | [
19,
4
] | [
30,
9
] | python | en | ['en', 'no', 'en'] | True |
FluNearYouFlowHandler.async_step_user | (self, user_input=None) | Handle the start of the config flow. | Handle the start of the config flow. | async def async_step_user(self, user_input=None):
"""Handle the start of the config flow."""
if not user_input:
return self.async_show_form(step_id="user", data_schema=self.data_schema)
unique_id = f"{user_input[CONF_LATITUDE]}, {user_input[CONF_LONGITUDE]}"
await self.asyn... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"not",
"user_input",
":",
"return",
"self",
".",
"async_show_form",
"(",
"step_id",
"=",
"\"user\"",
",",
"data_schema",
"=",
"self",
".",
"data_schema",
")",
"... | [
32,
4
] | [
53,
72
] | python | en | ['en', 'en', 'en'] | True |
initialize | (hass, client_id, client_secret) | Initialize a local auth provider. | Initialize a local auth provider. | def initialize(hass, client_id, client_secret):
"""Initialize a local auth provider."""
config_flow.register_flow_implementation(
hass,
DOMAIN,
"configuration.yaml",
partial(generate_auth_url, client_id),
partial(resolve_auth_code, hass, client_id, client_secret),
) | [
"def",
"initialize",
"(",
"hass",
",",
"client_id",
",",
"client_secret",
")",
":",
"config_flow",
".",
"register_flow_implementation",
"(",
"hass",
",",
"DOMAIN",
",",
"\"configuration.yaml\"",
",",
"partial",
"(",
"generate_auth_url",
",",
"client_id",
")",
",",... | [
14,
0
] | [
22,
5
] | python | en | ['en', 'en', 'en'] | True |
generate_auth_url | (client_id, flow_id) | Generate an authorize url. | Generate an authorize url. | async def generate_auth_url(client_id, flow_id):
"""Generate an authorize url."""
return AUTHORIZE_URL.format(client_id, flow_id) | [
"async",
"def",
"generate_auth_url",
"(",
"client_id",
",",
"flow_id",
")",
":",
"return",
"AUTHORIZE_URL",
".",
"format",
"(",
"client_id",
",",
"flow_id",
")"
] | [
25,
0
] | [
27,
51
] | python | en | ['de', 'en', 'en'] | True |
resolve_auth_code | (hass, client_id, client_secret, code) | Resolve an authorization code. | Resolve an authorization code. | async def resolve_auth_code(hass, client_id, client_secret, code):
"""Resolve an authorization code."""
result = asyncio.Future()
auth = NestAuth(
client_id=client_id,
client_secret=client_secret,
auth_callback=result.set_result,
)
auth.pin = code
try:
await has... | [
"async",
"def",
"resolve_auth_code",
"(",
"hass",
",",
"client_id",
",",
"client_secret",
",",
"code",
")",
":",
"result",
"=",
"asyncio",
".",
"Future",
"(",
")",
"auth",
"=",
"NestAuth",
"(",
"client_id",
"=",
"client_id",
",",
"client_secret",
"=",
"cli... | [
30,
0
] | [
49,
9
] | python | en | ['de', 'en', 'en'] | True |
test_aqara_gateway_setup | (hass) | Test that a Aqara Gateway can be correctly setup in HA. | Test that a Aqara Gateway can be correctly setup in HA. | async def test_aqara_gateway_setup(hass):
"""Test that a Aqara Gateway can be correctly setup in HA."""
accessories = await setup_accessories_from_file(hass, "aqara_gateway.json")
config_entry, pairing = await setup_test_accessories(hass, accessories)
entity_registry = await hass.helpers.entity_registr... | [
"async",
"def",
"test_aqara_gateway_setup",
"(",
"hass",
")",
":",
"accessories",
"=",
"await",
"setup_accessories_from_file",
"(",
"hass",
",",
"\"aqara_gateway.json\"",
")",
"config_entry",
",",
"pairing",
"=",
"await",
"setup_test_accessories",
"(",
"hass",
",",
... | [
15,
0
] | [
61,
39
] | python | en | ['en', 'ig', 'en'] | True |
calls | (hass) | Track calls to a mock service. | Track calls to a mock service. | def calls(hass):
"""Track calls to a mock service."""
return async_mock_service(hass, "test", "automation") | [
"def",
"calls",
"(",
"hass",
")",
":",
"return",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"automation\"",
")"
] | [
12,
0
] | [
14,
57
] | python | en | ['en', 'en', 'en'] | True |
setup_comp | (hass) | Initialize components. | Initialize components. | def setup_comp(hass):
"""Initialize components."""
mock_component(hass, "group")
hass.loop.run_until_complete(
async_setup_component(
hass,
zone.DOMAIN,
{
"zone": {
"name": "test",
"latitude": 32.880837,
... | [
"def",
"setup_comp",
"(",
"hass",
")",
":",
"mock_component",
"(",
"hass",
",",
"\"group\"",
")",
"hass",
".",
"loop",
".",
"run_until_complete",
"(",
"async_setup_component",
"(",
"hass",
",",
"zone",
".",
"DOMAIN",
",",
"{",
"\"zone\"",
":",
"{",
"\"name... | [
18,
0
] | [
34,
5
] | python | en | ['de', 'en', 'en'] | False |
test_if_fires_on_zone_enter | (hass, calls) | Test for firing on zone enter. | Test for firing on zone enter. | async def test_if_fires_on_zone_enter(hass, calls):
"""Test for firing on zone enter."""
context = Context()
hass.states.async_set(
"geo_location.entity",
"hello",
{"latitude": 32.881011, "longitude": -117.234758, "source": "test_source"},
)
await hass.async_block_till_done()... | [
"async",
"def",
"test_if_fires_on_zone_enter",
"(",
"hass",
",",
"calls",
")",
":",
"context",
"=",
"Context",
"(",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"geo_location.entity\"",
",",
"\"hello\"",
",",
"{",
"\"latitude\"",
":",
"32.881011",
",",... | [
37,
0
] | [
114,
26
] | python | en | ['en', 'no', 'en'] | True |
test_if_not_fires_for_enter_on_zone_leave | (hass, calls) | Test for not firing on zone leave. | Test for not firing on zone leave. | async def test_if_not_fires_for_enter_on_zone_leave(hass, calls):
"""Test for not firing on zone leave."""
hass.states.async_set(
"geo_location.entity",
"hello",
{"latitude": 32.880586, "longitude": -117.237564, "source": "test_source"},
)
await hass.async_block_till_done()
... | [
"async",
"def",
"test_if_not_fires_for_enter_on_zone_leave",
"(",
"hass",
",",
"calls",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"geo_location.entity\"",
",",
"\"hello\"",
",",
"{",
"\"latitude\"",
":",
"32.880586",
",",
"\"longitude\"",
":",
"-",... | [
117,
0
] | [
149,
26
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_zone_leave | (hass, calls) | Test for firing on zone leave. | Test for firing on zone leave. | async def test_if_fires_on_zone_leave(hass, calls):
"""Test for firing on zone leave."""
hass.states.async_set(
"geo_location.entity",
"hello",
{"latitude": 32.880586, "longitude": -117.237564, "source": "test_source"},
)
await hass.async_block_till_done()
assert await async... | [
"async",
"def",
"test_if_fires_on_zone_leave",
"(",
"hass",
",",
"calls",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"geo_location.entity\"",
",",
"\"hello\"",
",",
"{",
"\"latitude\"",
":",
"32.880586",
",",
"\"longitude\"",
":",
"-",
"117.237564... | [
152,
0
] | [
184,
26
] | python | en | ['en', 'en', 'en'] | True |
test_if_not_fires_for_leave_on_zone_enter | (hass, calls) | Test for not firing on zone enter. | Test for not firing on zone enter. | async def test_if_not_fires_for_leave_on_zone_enter(hass, calls):
"""Test for not firing on zone enter."""
hass.states.async_set(
"geo_location.entity",
"hello",
{"latitude": 32.881011, "longitude": -117.234758, "source": "test_source"},
)
await hass.async_block_till_done()
... | [
"async",
"def",
"test_if_not_fires_for_leave_on_zone_enter",
"(",
"hass",
",",
"calls",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"geo_location.entity\"",
",",
"\"hello\"",
",",
"{",
"\"latitude\"",
":",
"32.881011",
",",
"\"longitude\"",
":",
"-",... | [
187,
0
] | [
219,
26
] | python | en | ['en', 'no', 'en'] | True |
test_if_fires_on_zone_appear | (hass, calls) | Test for firing if entity appears in zone. | Test for firing if entity appears in zone. | async def test_if_fires_on_zone_appear(hass, calls):
"""Test for firing if entity appears in zone."""
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": {
"platform": "geo_location",
... | [
"async",
"def",
"test_if_fires_on_zone_appear",
"(",
"hass",
",",
"calls",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",
"{",
"\"trigger\"",
":",
"{",
"\"platfor... | [
222,
0
] | [
268,
5
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_zone_disappear | (hass, calls) | Test for firing if entity disappears from zone. | Test for firing if entity disappears from zone. | async def test_if_fires_on_zone_disappear(hass, calls):
"""Test for firing if entity disappears from zone."""
hass.states.async_set(
"geo_location.entity",
"hello",
{"latitude": 32.880586, "longitude": -117.237564, "source": "test_source"},
)
await hass.async_block_till_done()
... | [
"async",
"def",
"test_if_fires_on_zone_disappear",
"(",
"hass",
",",
"calls",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"geo_location.entity\"",
",",
"\"hello\"",
",",
"{",
"\"latitude\"",
":",
"32.880586",
",",
"\"longitude\"",
":",
"-",
"117.23... | [
271,
0
] | [
317,
5
] | python | en | ['en', 'en', 'en'] | True |
get_scanner | (hass, config) | Validate the configuration and return a Cisco scanner. | Validate the configuration and return a Cisco scanner. | def get_scanner(hass, config):
"""Validate the configuration and return a Cisco scanner."""
scanner = CiscoDeviceScanner(config[DOMAIN])
return scanner if scanner.success_init else None | [
"def",
"get_scanner",
"(",
"hass",
",",
"config",
")",
":",
"scanner",
"=",
"CiscoDeviceScanner",
"(",
"config",
"[",
"DOMAIN",
"]",
")",
"return",
"scanner",
"if",
"scanner",
".",
"success_init",
"else",
"None"
] | [
29,
0
] | [
33,
52
] | python | en | ['en', 'en', 'en'] | True |
_parse_cisco_mac_address | (cisco_hardware_addr) |
Parse a Cisco formatted HW address to normal MAC.
e.g. convert
001d.ec02.07ab
to:
00:1D:EC:02:07:AB
Takes in cisco_hwaddr: HWAddr String from Cisco ARP table
Returns a regular standard MAC address
|
Parse a Cisco formatted HW address to normal MAC. | def _parse_cisco_mac_address(cisco_hardware_addr):
"""
Parse a Cisco formatted HW address to normal MAC.
e.g. convert
001d.ec02.07ab
to:
00:1D:EC:02:07:AB
Takes in cisco_hwaddr: HWAddr String from Cisco ARP table
Returns a regular standard MAC address
"""
cisco_hardware_addr =... | [
"def",
"_parse_cisco_mac_address",
"(",
"cisco_hardware_addr",
")",
":",
"cisco_hardware_addr",
"=",
"cisco_hardware_addr",
".",
"replace",
"(",
"\".\"",
",",
"\"\"",
")",
"blocks",
"=",
"[",
"cisco_hardware_addr",
"[",
"x",
":",
"x",
"+",
"2",
"]",
"for",
"x"... | [
139,
0
] | [
157,
35
] | python | en | ['en', 'error', 'th'] | False |
CiscoDeviceScanner.__init__ | (self, config) | Initialize the scanner. | Initialize the scanner. | def __init__(self, config):
"""Initialize the scanner."""
self.host = config[CONF_HOST]
self.username = config[CONF_USERNAME]
self.port = config.get(CONF_PORT)
self.password = config[CONF_PASSWORD]
self.last_results = {}
self.success_init = self._update_info()
... | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"host",
"=",
"config",
"[",
"CONF_HOST",
"]",
"self",
".",
"username",
"=",
"config",
"[",
"CONF_USERNAME",
"]",
"self",
".",
"port",
"=",
"config",
".",
"get",
"(",
"CONF_PORT",
"... | [
39,
4
] | [
49,
53
] | python | en | ['en', 'en', 'en'] | True |
CiscoDeviceScanner.get_device_name | (self, device) | Get the firmware doesn't save the name of the wireless device. | Get the firmware doesn't save the name of the wireless device. | def get_device_name(self, device):
"""Get the firmware doesn't save the name of the wireless device."""
return None | [
"def",
"get_device_name",
"(",
"self",
",",
"device",
")",
":",
"return",
"None"
] | [
51,
4
] | [
53,
19
] | python | en | ['en', 'en', 'en'] | True |
CiscoDeviceScanner.scan_devices | (self) | Scan for new devices and return a list with found device IDs. | Scan for new devices and return a list with found device IDs. | def scan_devices(self):
"""Scan for new devices and return a list with found device IDs."""
self._update_info()
return self.last_results | [
"def",
"scan_devices",
"(",
"self",
")",
":",
"self",
".",
"_update_info",
"(",
")",
"return",
"self",
".",
"last_results"
] | [
55,
4
] | [
59,
32
] | python | en | ['en', 'en', 'en'] | True |
CiscoDeviceScanner._update_info | (self) |
Ensure the information from the Cisco router is up to date.
Returns boolean if scanning successful.
|
Ensure the information from the Cisco router is up to date. | def _update_info(self):
"""
Ensure the information from the Cisco router is up to date.
Returns boolean if scanning successful.
"""
string_result = self._get_arp_data()
if string_result:
self.last_results = []
last_results = []
lines... | [
"def",
"_update_info",
"(",
"self",
")",
":",
"string_result",
"=",
"self",
".",
"_get_arp_data",
"(",
")",
"if",
"string_result",
":",
"self",
".",
"last_results",
"=",
"[",
"]",
"last_results",
"=",
"[",
"]",
"lines_result",
"=",
"string_result",
".",
"s... | [
61,
4
] | [
100,
20
] | python | en | ['en', 'error', 'th'] | False |
CiscoDeviceScanner._get_arp_data | (self) | Open connection to the router and get arp entries. | Open connection to the router and get arp entries. | def _get_arp_data(self):
"""Open connection to the router and get arp entries."""
try:
cisco_ssh = pxssh.pxssh()
cisco_ssh.login(
self.host,
self.username,
self.password,
port=self.port,
auto_prompt_... | [
"def",
"_get_arp_data",
"(",
"self",
")",
":",
"try",
":",
"cisco_ssh",
"=",
"pxssh",
".",
"pxssh",
"(",
")",
"cisco_ssh",
".",
"login",
"(",
"self",
".",
"host",
",",
"self",
".",
"username",
",",
"self",
".",
"password",
",",
"port",
"=",
"self",
... | [
102,
4
] | [
136,
19
] | python | en | ['en', 'en', 'en'] | True |
test_reproducing_states | (hass, caplog) | Test reproducing Lock states. | Test reproducing Lock states. | async def test_reproducing_states(hass, caplog):
"""Test reproducing Lock states."""
hass.states.async_set("lock.entity_locked", "locked", {})
hass.states.async_set("lock.entity_unlocked", "unlocked", {})
lock_calls = async_mock_service(hass, "lock", "lock")
unlock_calls = async_mock_service(hass, ... | [
"async",
"def",
"test_reproducing_states",
"(",
"hass",
",",
"caplog",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"lock.entity_locked\"",
",",
"\"locked\"",
",",
"{",
"}",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"lock.entity_unlocke... | [
6,
0
] | [
50,
70
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Efergy sensor. | Set up the Efergy sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Efergy sensor."""
app_token = config.get(CONF_APPTOKEN)
utc_offset = str(config.get(CONF_UTC_OFFSET))
dev = []
for variable in config[CONF_MONITORED_VARIABLES]:
if variable[CONF_SENSOR_TYPE] == CONF_CURRENT_V... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"app_token",
"=",
"config",
".",
"get",
"(",
"CONF_APPTOKEN",
")",
"utc_offset",
"=",
"str",
"(",
"config",
".",
"get",
"(",
"CONF_UTC_O... | [
57,
0
] | [
89,
27
] | python | en | ['en', 'pt', 'en'] | True |
EfergySensor.__init__ | (self, sensor_type, app_token, utc_offset, period, currency, sid=None) | Initialize the sensor. | Initialize the sensor. | def __init__(self, sensor_type, app_token, utc_offset, period, currency, sid=None):
"""Initialize the sensor."""
self.sid = sid
if sid:
self._name = f"efergy_{sid}"
else:
self._name = SENSOR_TYPES[sensor_type][0]
self.type = sensor_type
self.app_to... | [
"def",
"__init__",
"(",
"self",
",",
"sensor_type",
",",
"app_token",
",",
"utc_offset",
",",
"period",
",",
"currency",
",",
"sid",
"=",
"None",
")",
":",
"self",
".",
"sid",
"=",
"sid",
"if",
"sid",
":",
"self",
".",
"_name",
"=",
"f\"efergy_{sid}\""... | [
95,
4
] | [
111,
68
] | python | en | ['en', 'en', 'en'] | True |
EfergySensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
114,
4
] | [
116,
25
] | python | en | ['en', 'mi', 'en'] | True |
EfergySensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
119,
4
] | [
121,
26
] | python | en | ['en', 'en', 'en'] | True |
EfergySensor.unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
124,
4
] | [
126,
40
] | python | en | ['en', 'en', 'en'] | True |
EfergySensor.update | (self) | Get the Efergy monitor data from the web service. | Get the Efergy monitor data from the web service. | def update(self):
"""Get the Efergy monitor data from the web service."""
try:
if self.type == "instant_readings":
url_string = f"{_RESOURCE}getInstant?token={self.app_token}"
response = requests.get(url_string, timeout=10)
self._state = respon... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"if",
"self",
".",
"type",
"==",
"\"instant_readings\"",
":",
"url_string",
"=",
"f\"{_RESOURCE}getInstant?token={self.app_token}\"",
"response",
"=",
"requests",
".",
"get",
"(",
"url_string",
",",
"timeout",
... | [
128,
4
] | [
159,
72
] | python | en | ['en', 'en', 'en'] | True |
ensure_unique_hosts | (value) | Validate that all configs have a unique host. | Validate that all configs have a unique host. | def ensure_unique_hosts(value):
"""Validate that all configs have a unique host."""
vol.Schema(vol.Unique("duplicate host entries found"))(
[socket.gethostbyname(entry[CONF_HOST]) for entry in value]
)
return value | [
"def",
"ensure_unique_hosts",
"(",
"value",
")",
":",
"vol",
".",
"Schema",
"(",
"vol",
".",
"Unique",
"(",
"\"duplicate host entries found\"",
")",
")",
"(",
"[",
"socket",
".",
"gethostbyname",
"(",
"entry",
"[",
"CONF_HOST",
"]",
")",
"for",
"entry",
"i... | [
12,
0
] | [
17,
16
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the Samsung TV integration. | Set up the Samsung TV integration. | async def async_setup(hass, config):
"""Set up the Samsung TV integration."""
if DOMAIN in config:
hass.data[DOMAIN] = {}
for entry_config in config[DOMAIN]:
ip_address = await hass.async_add_executor_job(
socket.gethostbyname, entry_config[CONF_HOST]
)
... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"if",
"DOMAIN",
"in",
"config",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"}",
"for",
"entry_config",
"in",
"config",
"[",
"DOMAIN",
"]",
":",
"ip_address",
"=",
"awai... | [
42,
0
] | [
59,
15
] | python | en | ['en', 'da', 'en'] | True |
async_setup_entry | (hass, entry) | Set up the Samsung TV platform. | Set up the Samsung TV platform. | async def async_setup_entry(hass, entry):
"""Set up the Samsung TV platform."""
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, MP_DOMAIN)
)
return True | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"hass",
".",
"async_create_task",
"(",
"hass",
".",
"config_entries",
".",
"async_forward_entry_setup",
"(",
"entry",
",",
"MP_DOMAIN",
")",
")",
"return",
"True"
] | [
62,
0
] | [
68,
15
] | python | en | ['en', 'da', 'en'] | True |
lovasz_grad | (gt_sorted) |
Computes gradient of the Lovasz extension w.r.t sorted errors
See Alg. 1 in paper
|
Computes gradient of the Lovasz extension w.r.t sorted errors
See Alg. 1 in paper
| def lovasz_grad(gt_sorted):
"""
Computes gradient of the Lovasz extension w.r.t sorted errors
See Alg. 1 in paper
"""
p = len(gt_sorted)
gts = gt_sorted.sum()
intersection = gts - gt_sorted.float().cumsum(0)
union = gts + (1 - gt_sorted).float().cumsum(0)
jaccard = 1. - intersection ... | [
"def",
"lovasz_grad",
"(",
"gt_sorted",
")",
":",
"p",
"=",
"len",
"(",
"gt_sorted",
")",
"gts",
"=",
"gt_sorted",
".",
"sum",
"(",
")",
"intersection",
"=",
"gts",
"-",
"gt_sorted",
".",
"float",
"(",
")",
".",
"cumsum",
"(",
"0",
")",
"union",
"=... | [
35,
0
] | [
47,
18
] | python | en | ['en', 'error', 'th'] | False |
iou_binary | (preds, labels, EMPTY=1., ignore=None, per_image=True) |
IoU for foreground class
binary: 1 foreground, 0 background
|
IoU for foreground class
binary: 1 foreground, 0 background
| def iou_binary(preds, labels, EMPTY=1., ignore=None, per_image=True):
"""
IoU for foreground class
binary: 1 foreground, 0 background
"""
if not per_image:
preds, labels = (preds,), (labels,)
ious = []
for pred, label in zip(preds, labels):
intersection = ((label == 1) & (pre... | [
"def",
"iou_binary",
"(",
"preds",
",",
"labels",
",",
"EMPTY",
"=",
"1.",
",",
"ignore",
"=",
"None",
",",
"per_image",
"=",
"True",
")",
":",
"if",
"not",
"per_image",
":",
"preds",
",",
"labels",
"=",
"(",
"preds",
",",
")",
",",
"(",
"labels",
... | [
50,
0
] | [
67,
20
] | python | en | ['en', 'error', 'th'] | False |
iou | (preds, labels, C, EMPTY=1., ignore=None, per_image=False) |
Array of IoU for each (non ignored) class
|
Array of IoU for each (non ignored) class
| def iou(preds, labels, C, EMPTY=1., ignore=None, per_image=False):
"""
Array of IoU for each (non ignored) class
"""
if not per_image:
preds, labels = (preds,), (labels,)
ious = []
for pred, label in zip(preds, labels):
iou = []
for i in range(C):
if i != igno... | [
"def",
"iou",
"(",
"preds",
",",
"labels",
",",
"C",
",",
"EMPTY",
"=",
"1.",
",",
"ignore",
"=",
"None",
",",
"per_image",
"=",
"False",
")",
":",
"if",
"not",
"per_image",
":",
"preds",
",",
"labels",
"=",
"(",
"preds",
",",
")",
",",
"(",
"l... | [
70,
0
] | [
89,
31
] | python | en | ['en', 'error', 'th'] | False |
lovasz_hinge | (logits, labels, per_image=True, ignore=None) |
Binary Lovasz hinge loss
logits: [B, H, W] Variable, logits at each pixel (between -\infty and +\infty)
labels: [B, H, W] Tensor, binary ground truth masks (0 or 1)
per_image: compute the loss per image instead of per batch
ignore: void class id
|
Binary Lovasz hinge loss
logits: [B, H, W] Variable, logits at each pixel (between -\infty and +\infty)
labels: [B, H, W] Tensor, binary ground truth masks (0 or 1)
per_image: compute the loss per image instead of per batch
ignore: void class id
| def lovasz_hinge(logits, labels, per_image=True, ignore=None):
"""
Binary Lovasz hinge loss
logits: [B, H, W] Variable, logits at each pixel (between -\infty and +\infty)
labels: [B, H, W] Tensor, binary ground truth masks (0 or 1)
per_image: compute the loss per image instead of per batch
... | [
"def",
"lovasz_hinge",
"(",
"logits",
",",
"labels",
",",
"per_image",
"=",
"True",
",",
"ignore",
"=",
"None",
")",
":",
"if",
"per_image",
":",
"loss",
"=",
"mean",
"(",
"lovasz_hinge_flat",
"(",
"*",
"flatten_binary_scores",
"(",
"log",
".",
"unsqueeze"... | [
95,
0
] | [
108,
15
] | python | en | ['en', 'error', 'th'] | False |
lovasz_hinge_flat | (logits, labels) |
Binary Lovasz hinge loss
logits: [P] Variable, logits at each prediction (between -\infty and +\infty)
labels: [P] Tensor, binary ground truth labels (0 or 1)
ignore: label to ignore
|
Binary Lovasz hinge loss
logits: [P] Variable, logits at each prediction (between -\infty and +\infty)
labels: [P] Tensor, binary ground truth labels (0 or 1)
ignore: label to ignore
| def lovasz_hinge_flat(logits, labels):
"""
Binary Lovasz hinge loss
logits: [P] Variable, logits at each prediction (between -\infty and +\infty)
labels: [P] Tensor, binary ground truth labels (0 or 1)
ignore: label to ignore
"""
if len(labels) == 0:
# only void pixels, the gra... | [
"def",
"lovasz_hinge_flat",
"(",
"logits",
",",
"labels",
")",
":",
"if",
"len",
"(",
"labels",
")",
"==",
"0",
":",
"# only void pixels, the gradients should be 0",
"return",
"logits",
".",
"sum",
"(",
")",
"*",
"0.",
"signs",
"=",
"2.",
"*",
"labels",
".... | [
111,
0
] | [
130,
15
] | python | en | ['en', 'error', 'th'] | False |
flatten_binary_scores | (scores, labels, ignore=None) |
Flattens predictions in the batch (binary case)
Remove labels equal to 'ignore'
|
Flattens predictions in the batch (binary case)
Remove labels equal to 'ignore'
| def flatten_binary_scores(scores, labels, ignore=None):
"""
Flattens predictions in the batch (binary case)
Remove labels equal to 'ignore'
"""
scores = scores.view(-1)
labels = labels.view(-1)
if ignore is None:
return scores, labels
valid = (labels != ignore)
vscores = scor... | [
"def",
"flatten_binary_scores",
"(",
"scores",
",",
"labels",
",",
"ignore",
"=",
"None",
")",
":",
"scores",
"=",
"scores",
".",
"view",
"(",
"-",
"1",
")",
"labels",
"=",
"labels",
".",
"view",
"(",
"-",
"1",
")",
"if",
"ignore",
"is",
"None",
":... | [
133,
0
] | [
145,
27
] | python | en | ['en', 'error', 'th'] | False |
binary_xloss | (logits, labels, ignore=None) |
Binary Cross entropy loss
logits: [B, H, W] Variable, logits at each pixel (between -\infty and +\infty)
labels: [B, H, W] Tensor, binary ground truth masks (0 or 1)
ignore: void class id
|
Binary Cross entropy loss
logits: [B, H, W] Variable, logits at each pixel (between -\infty and +\infty)
labels: [B, H, W] Tensor, binary ground truth masks (0 or 1)
ignore: void class id
| def binary_xloss(logits, labels, ignore=None):
"""
Binary Cross entropy loss
logits: [B, H, W] Variable, logits at each pixel (between -\infty and +\infty)
labels: [B, H, W] Tensor, binary ground truth masks (0 or 1)
ignore: void class id
"""
logits, labels = flatten_binary_scores(logi... | [
"def",
"binary_xloss",
"(",
"logits",
",",
"labels",
",",
"ignore",
"=",
"None",
")",
":",
"logits",
",",
"labels",
"=",
"flatten_binary_scores",
"(",
"logits",
",",
"labels",
",",
"ignore",
")",
"loss",
"=",
"StableBCELoss",
"(",
")",
"(",
"logits",
","... | [
157,
0
] | [
166,
15
] | python | en | ['en', 'error', 'th'] | False |
lovasz_softmax | (probas, labels, only_present=False, per_image=False, ignore=None) |
Multi-class Lovasz-Softmax loss
probas: [B, C, H, W] Variable, class probabilities at each prediction (between 0 and 1)
labels: [B, H, W] Tensor, ground truth labels (between 0 and C - 1)
only_present: average only on classes present in ground truth
per_image: compute the loss per image ins... |
Multi-class Lovasz-Softmax loss
probas: [B, C, H, W] Variable, class probabilities at each prediction (between 0 and 1)
labels: [B, H, W] Tensor, ground truth labels (between 0 and C - 1)
only_present: average only on classes present in ground truth
per_image: compute the loss per image ins... | def lovasz_softmax(probas, labels, only_present=False, per_image=False, ignore=None):
"""
Multi-class Lovasz-Softmax loss
probas: [B, C, H, W] Variable, class probabilities at each prediction (between 0 and 1)
labels: [B, H, W] Tensor, ground truth labels (between 0 and C - 1)
only_present: av... | [
"def",
"lovasz_softmax",
"(",
"probas",
",",
"labels",
",",
"only_present",
"=",
"False",
",",
"per_image",
"=",
"False",
",",
"ignore",
"=",
"None",
")",
":",
"if",
"per_image",
":",
"loss",
"=",
"mean",
"(",
"lovasz_softmax_flat",
"(",
"*",
"flatten_prob... | [
172,
0
] | [
186,
15
] | python | en | ['en', 'error', 'th'] | False |
lovasz_softmax_flat | (probas, labels, only_present=False) |
Multi-class Lovasz-Softmax loss
probas: [P, C] Variable, class probabilities at each prediction (between 0 and 1)
labels: [P] Tensor, ground truth labels (between 0 and C - 1)
only_present: average only on classes present in ground truth
|
Multi-class Lovasz-Softmax loss
probas: [P, C] Variable, class probabilities at each prediction (between 0 and 1)
labels: [P] Tensor, ground truth labels (between 0 and C - 1)
only_present: average only on classes present in ground truth
| def lovasz_softmax_flat(probas, labels, only_present=False):
"""
Multi-class Lovasz-Softmax loss
probas: [P, C] Variable, class probabilities at each prediction (between 0 and 1)
labels: [P] Tensor, ground truth labels (between 0 and C - 1)
only_present: average only on classes present in grou... | [
"def",
"lovasz_softmax_flat",
"(",
"probas",
",",
"labels",
",",
"only_present",
"=",
"False",
")",
":",
"C",
"=",
"probas",
".",
"size",
"(",
"1",
")",
"losses",
"=",
"[",
"]",
"for",
"c",
"in",
"range",
"(",
"C",
")",
":",
"fg",
"=",
"(",
"labe... | [
189,
0
] | [
207,
23
] | python | en | ['en', 'error', 'th'] | False |
flatten_probas | (probas, labels, ignore=None) |
Flattens predictions in the batch
|
Flattens predictions in the batch
| def flatten_probas(probas, labels, ignore=None):
"""
Flattens predictions in the batch
"""
B, C, H, W = probas.size()
probas = probas.permute(0, 2, 3, 1).contiguous().view(-1, C) # B * H * W, C = P, C
labels = labels.view(-1)
if ignore is None:
return probas, labels
valid = (lab... | [
"def",
"flatten_probas",
"(",
"probas",
",",
"labels",
",",
"ignore",
"=",
"None",
")",
":",
"B",
",",
"C",
",",
"H",
",",
"W",
"=",
"probas",
".",
"size",
"(",
")",
"probas",
"=",
"probas",
".",
"permute",
"(",
"0",
",",
"2",
",",
"3",
",",
... | [
210,
0
] | [
222,
27
] | python | en | ['en', 'error', 'th'] | False |
xloss | (logits, labels, ignore=None) |
Cross entropy loss
|
Cross entropy loss
| def xloss(logits, labels, ignore=None):
"""
Cross entropy loss
"""
return F.cross_entropy(logits, Variable(labels), ignore_index=255) | [
"def",
"xloss",
"(",
"logits",
",",
"labels",
",",
"ignore",
"=",
"None",
")",
":",
"return",
"F",
".",
"cross_entropy",
"(",
"logits",
",",
"Variable",
"(",
"labels",
")",
",",
"ignore_index",
"=",
"255",
")"
] | [
224,
0
] | [
228,
70
] | python | en | ['en', 'error', 'th'] | False |
mean | (l, ignore_nan=False, empty=0) |
nanmean compatible with generators.
|
nanmean compatible with generators.
| def mean(l, ignore_nan=False, empty=0):
"""
nanmean compatible with generators.
"""
l = iter(l)
if ignore_nan:
l = ifilterfalse(np.isnan, l)
try:
n = 1
acc = next(l)
except StopIteration:
if empty == 'raise':
raise ValueError('Empty mean')
... | [
"def",
"mean",
"(",
"l",
",",
"ignore_nan",
"=",
"False",
",",
"empty",
"=",
"0",
")",
":",
"l",
"=",
"iter",
"(",
"l",
")",
"if",
"ignore_nan",
":",
"l",
"=",
"ifilterfalse",
"(",
"np",
".",
"isnan",
",",
"l",
")",
"try",
":",
"n",
"=",
"1",... | [
233,
0
] | [
251,
18
] | python | en | ['en', 'error', 'th'] | False |
CitiBikePipeline.download | (self, is_force: bool = False) | Download the zip file. | Download the zip file. | def download(self, is_force: bool = False):
"""Download the zip file."""
super().download(is_force)
self._new_file_list.append(self._station_info_file)
if (not is_force) and os.path.exists(self._station_info_file):
logger.info_green("File already exists, skipping download.")... | [
"def",
"download",
"(",
"self",
",",
"is_force",
":",
"bool",
"=",
"False",
")",
":",
"super",
"(",
")",
".",
"download",
"(",
"is_force",
")",
"self",
".",
"_new_file_list",
".",
"append",
"(",
"self",
".",
"_station_info_file",
")",
"if",
"(",
"not",... | [
64,
4
] | [
73,
89
] | python | en | ['en', 'en', 'en'] | True |
CitiBikePipeline.clean | (self) | Unzip the csv file and process it for building binary file. | Unzip the csv file and process it for building binary file. | def clean(self):
"""Unzip the csv file and process it for building binary file."""
super().clean()
logger.info_green("Cleaning trip data.")
if os.path.exists(self._download_file):
# unzip
logger.info_green("Unzip start.")
with zipfile.ZipFile(self._dow... | [
"def",
"clean",
"(",
"self",
")",
":",
"super",
"(",
")",
".",
"clean",
"(",
")",
"logger",
".",
"info_green",
"(",
"\"Cleaning trip data.\"",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"_download_file",
")",
":",
"# unzip",
"logger... | [
75,
4
] | [
98,
85
] | python | en | ['en', 'en', 'en'] | True |
CitiBikePipeline._read_common_data | (self) | Read and full init data and existed stations. | Read and full init data and existed stations. | def _read_common_data(self):
"""Read and full init data and existed stations."""
full_stations = None
with open(self._station_info_file, mode="r", encoding="utf-8") as station_file:
# read station to station file
raw_station_data = pd.DataFrame.from_dict(pd.read_json(st... | [
"def",
"_read_common_data",
"(",
"self",
")",
":",
"full_stations",
"=",
"None",
"with",
"open",
"(",
"self",
".",
"_station_info_file",
",",
"mode",
"=",
"\"r\"",
",",
"encoding",
"=",
"\"utf-8\"",
")",
"as",
"station_file",
":",
"# read station to station file... | [
100,
4
] | [
132,
97
] | python | en | ['en', 'en', 'en'] | True |
CitiBikePipeline._read_src_file | (self, file: str) | Read and return processed rows. | Read and return processed rows. | def _read_src_file(self, file: str):
"""Read and return processed rows."""
ret = []
if os.path.exists(file):
# For ignoring the unimportant issues in the source file.
with open(file, "r", encoding="utf-8", errors="ignore") as fp:
ret = pd.read_csv(fp)
... | [
"def",
"_read_src_file",
"(",
"self",
",",
"file",
":",
"str",
")",
":",
"ret",
"=",
"[",
"]",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"file",
")",
":",
"# For ignoring the unimportant issues in the source file.",
"with",
"open",
"(",
"file",
",",
"\"... | [
134,
4
] | [
180,
18
] | python | en | ['en', 'en', 'en'] | True |
WeatherPipeline.clean | (self) | Clean the original data file. | Clean the original data file. | def clean(self):
"""Clean the original data file."""
super().clean()
if os.path.exists(self._download_file):
self._new_file_list.append(self._clean_file)
logger.info_green("Cleaning weather data.")
self._preprocess(input_file=self._download_file, output_file=s... | [
"def",
"clean",
"(",
"self",
")",
":",
"super",
"(",
")",
".",
"clean",
"(",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"_download_file",
")",
":",
"self",
".",
"_new_file_list",
".",
"append",
"(",
"self",
".",
"_clean_file",
"... | [
345,
4
] | [
353,
88
] | python | en | ['en', 'co', 'en'] | True |
CitiBikeToyPipeline.download | (self, is_force: bool) | Toy datapipeline not need download process. | Toy datapipeline not need download process. | def download(self, is_force: bool):
"""Toy datapipeline not need download process."""
pass | [
"def",
"download",
"(",
"self",
",",
"is_force",
":",
"bool",
")",
":",
"pass"
] | [
465,
4
] | [
467,
12
] | python | en | ['en', 'en', 'en'] | True |
CitiBikeToyPipeline._station_dict_to_pd | (self, station_dict) | Convert dictionary of station information to pd series. | Convert dictionary of station information to pd series. | def _station_dict_to_pd(self, station_dict):
"""Convert dictionary of station information to pd series."""
return pd.Series(
[
station_dict["id"],
station_dict["capacity"],
station_dict["init"],
station_dict["lat"],
... | [
"def",
"_station_dict_to_pd",
"(",
"self",
",",
"station_dict",
")",
":",
"return",
"pd",
".",
"Series",
"(",
"[",
"station_dict",
"[",
"\"id\"",
"]",
",",
"station_dict",
"[",
"\"capacity\"",
"]",
",",
"station_dict",
"[",
"\"init\"",
"]",
",",
"station_dic... | [
469,
4
] | [
479,
81
] | python | en | ['en', 'en', 'en'] | True |
CitiBikeToyPipeline._gen_stations | (self) | Generate station meta csv. | Generate station meta csv. | def _gen_stations(self):
"""Generate station meta csv."""
self._new_file_list.append(self._station_meta_file)
stations = pd.Series(self._stations).apply(self._station_dict_to_pd)
stations["station_index"] = pd.to_numeric(stations["station_index"], errors="coerce", downcast="integer")
... | [
"def",
"_gen_stations",
"(",
"self",
")",
":",
"self",
".",
"_new_file_list",
".",
"append",
"(",
"self",
".",
"_station_meta_file",
")",
"stations",
"=",
"pd",
".",
"Series",
"(",
"self",
".",
"_stations",
")",
".",
"apply",
"(",
"self",
".",
"_station_... | [
481,
4
] | [
493,
23
] | python | bg | ['nl', 'jv', 'bg'] | False |
CitiBikeToyPipeline._gen_trip | (self, tick) | Generate trip record. | Generate trip record. | def _gen_trip(self, tick):
"""Generate trip record."""
ret_list = []
cur_probability = random.uniform(0, 1)
for trip in self._trips:
if trip["probability"] >= cur_probability:
ret = {}
ret["start_time"] = tick
ret["start_station... | [
"def",
"_gen_trip",
"(",
"self",
",",
"tick",
")",
":",
"ret_list",
"=",
"[",
"]",
"cur_probability",
"=",
"random",
".",
"uniform",
"(",
"0",
",",
"1",
")",
"for",
"trip",
"in",
"self",
".",
"_trips",
":",
"if",
"trip",
"[",
"\"probability\"",
"]",
... | [
495,
4
] | [
509,
23
] | python | co | ['en', 'co', 'it'] | False |
CitiBikeToyPipeline._gen_trips | (self) | Generate trip records csv files. | Generate trip records csv files. | def _gen_trips(self):
"""Generate trip records csv files."""
cur_tick = pd.to_datetime(self._start_time)
end_tick = pd.to_datetime(self._end_time)
trips = []
while cur_tick < end_tick:
new_trips = self._gen_trip(cur_tick)
trips.extend(new_trips)
... | [
"def",
"_gen_trips",
"(",
"self",
")",
":",
"cur_tick",
"=",
"pd",
".",
"to_datetime",
"(",
"self",
".",
"_start_time",
")",
"end_tick",
"=",
"pd",
".",
"to_datetime",
"(",
"self",
".",
"_end_time",
")",
"trips",
"=",
"[",
"]",
"while",
"cur_tick",
"<"... | [
511,
4
] | [
534,
23
] | python | en | ['sv', 'it', 'en'] | False |
CitiBikeToyPipeline._gen_distance | (self, station_init: pd.DataFrame) | Generate distance metrix csv file. | Generate distance metrix csv file. | def _gen_distance(self, station_init: pd.DataFrame):
"""Generate distance metrix csv file."""
distance_adj = pd.DataFrame(
0,
index=station_init["station_index"],
columns=station_init["station_index"],
dtype=np.float
)
look_up_df = station_... | [
"def",
"_gen_distance",
"(",
"self",
",",
"station_init",
":",
"pd",
".",
"DataFrame",
")",
":",
"distance_adj",
"=",
"pd",
".",
"DataFrame",
"(",
"0",
",",
"index",
"=",
"station_init",
"[",
"\"station_index\"",
"]",
",",
"columns",
"=",
"station_init",
"... | [
536,
4
] | [
553,
26
] | python | ht | ['wa', 'ht', 'it'] | False |
CitiBikeToyPipeline.clean | (self) | Clean the original data file. | Clean the original data file. | def clean(self):
"""Clean the original data file."""
logger.info_green(f"Generating trip data for topology {self._topology}.")
super().clean()
stations = self._gen_stations()
self._gen_trips()
self._gen_distance(stations) | [
"def",
"clean",
"(",
"self",
")",
":",
"logger",
".",
"info_green",
"(",
"f\"Generating trip data for topology {self._topology}.\"",
")",
"super",
"(",
")",
".",
"clean",
"(",
")",
"stations",
"=",
"self",
".",
"_gen_stations",
"(",
")",
"self",
".",
"_gen_tri... | [
555,
4
] | [
561,
36
] | python | en | ['en', 'co', 'en'] | True |
WeatherToyPipeline.download | (self, is_force: bool) | Toy datapipeline not need download process. | Toy datapipeline not need download process. | def download(self, is_force: bool):
"""Toy datapipeline not need download process."""
pass | [
"def",
"download",
"(",
"self",
",",
"is_force",
":",
"bool",
")",
":",
"pass"
] | [
589,
4
] | [
591,
12
] | python | en | ['en', 'en', 'en'] | True |
WeatherToyPipeline.clean | (self) | Clean the original data file. | Clean the original data file. | def clean(self):
"""Clean the original data file."""
logger.info_green("Cleaning weather data.")
DataPipeline.clean(self)
self._new_file_list.append(self._clean_file)
self._preprocess(output_file=self._clean_file) | [
"def",
"clean",
"(",
"self",
")",
":",
"logger",
".",
"info_green",
"(",
"\"Cleaning weather data.\"",
")",
"DataPipeline",
".",
"clean",
"(",
"self",
")",
"self",
".",
"_new_file_list",
".",
"append",
"(",
"self",
".",
"_clean_file",
")",
"self",
".",
"_p... | [
593,
4
] | [
598,
54
] | python | en | ['en', 'co', 'en'] | True |
NOAAWeatherPipeline.download | (self, is_force: bool) | Download the original data file. | Download the original data file. | def download(self, is_force: bool):
"""Download the original data file."""
super().download(is_force, self._gen_fall_back_file) | [
"def",
"download",
"(",
"self",
",",
"is_force",
":",
"bool",
")",
":",
"super",
"(",
")",
".",
"download",
"(",
"is_force",
",",
"self",
".",
"_gen_fall_back_file",
")"
] | [
737,
4
] | [
739,
60
] | python | en | ['en', 'id', 'en'] | True |
NOAAWeatherPipeline.clean | (self) | Clean the original data file. | Clean the original data file. | def clean(self):
"""Clean the original data file."""
DataPipeline.clean(self)
if os.path.exists(self._download_file):
self._new_file_list.append(self._clean_file)
logger.info_green("Cleaning weather data.")
self._preprocess(input_file=self._download_file, outp... | [
"def",
"clean",
"(",
"self",
")",
":",
"DataPipeline",
".",
"clean",
"(",
"self",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"_download_file",
")",
":",
"self",
".",
"_new_file_list",
".",
"append",
"(",
"self",
".",
"_clean_file",
... | [
741,
4
] | [
749,
88
] | python | en | ['en', 'co', 'en'] | True |
test_reproducing_on_off_states | (hass, caplog) | Test reproducing humidifier states. | Test reproducing humidifier states. | async def test_reproducing_on_off_states(hass, caplog):
"""Test reproducing humidifier states."""
hass.states.async_set(ENTITY_1, "off", {ATTR_MODE: MODE_NORMAL, ATTR_HUMIDITY: 45})
hass.states.async_set(ENTITY_2, "on", {ATTR_MODE: MODE_NORMAL, ATTR_HUMIDITY: 45})
turn_on_calls = async_mock_service(has... | [
"async",
"def",
"test_reproducing_on_off_states",
"(",
"hass",
",",
"caplog",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"ENTITY_1",
",",
"\"off\"",
",",
"{",
"ATTR_MODE",
":",
"MODE_NORMAL",
",",
"ATTR_HUMIDITY",
":",
"45",
"}",
")",
"hass",
... | [
24,
0
] | [
76,
35
] | python | en | ['en', 'en', 'en'] | True |
test_multiple_attrs | (hass) | Test turn on with multiple attributes. | Test turn on with multiple attributes. | async def test_multiple_attrs(hass):
"""Test turn on with multiple attributes."""
hass.states.async_set(ENTITY_1, STATE_OFF, {})
turn_on_calls = async_mock_service(hass, DOMAIN, SERVICE_TURN_ON)
turn_off_calls = async_mock_service(hass, DOMAIN, SERVICE_TURN_OFF)
mode_calls = async_mock_service(hass... | [
"async",
"def",
"test_multiple_attrs",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"ENTITY_1",
",",
"STATE_OFF",
",",
"{",
"}",
")",
"turn_on_calls",
"=",
"async_mock_service",
"(",
"hass",
",",
"DOMAIN",
",",
"SERVICE_TURN_ON",
")",... | [
79,
0
] | [
100,
76
] | python | en | ['en', 'en', 'en'] | True |
test_turn_off_multiple_attrs | (hass) | Test set mode and humidity for off state. | Test set mode and humidity for off state. | async def test_turn_off_multiple_attrs(hass):
"""Test set mode and humidity for off state."""
hass.states.async_set(ENTITY_1, STATE_ON, {})
turn_on_calls = async_mock_service(hass, DOMAIN, SERVICE_TURN_ON)
turn_off_calls = async_mock_service(hass, DOMAIN, SERVICE_TURN_OFF)
mode_calls = async_mock_s... | [
"async",
"def",
"test_turn_off_multiple_attrs",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"ENTITY_1",
",",
"STATE_ON",
",",
"{",
"}",
")",
"turn_on_calls",
"=",
"async_mock_service",
"(",
"hass",
",",
"DOMAIN",
",",
"SERVICE_TURN_ON"... | [
103,
0
] | [
122,
35
] | python | en | ['en', 'en', 'en'] | True |
test_multiple_modes | (hass) | Test that multiple states gets calls. | Test that multiple states gets calls. | async def test_multiple_modes(hass):
"""Test that multiple states gets calls."""
hass.states.async_set(ENTITY_1, STATE_OFF, {})
hass.states.async_set(ENTITY_2, STATE_OFF, {})
turn_on_calls = async_mock_service(hass, DOMAIN, SERVICE_TURN_ON)
turn_off_calls = async_mock_service(hass, DOMAIN, SERVICE_... | [
"async",
"def",
"test_multiple_modes",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"ENTITY_1",
",",
"STATE_OFF",
",",
"{",
"}",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"ENTITY_2",
",",
"STATE_OFF",
",",
"{",
"}",
")"... | [
125,
0
] | [
162,
5
] | python | en | ['en', 'en', 'en'] | True |
test_state_with_none | (hass) | Test that none is not a humidifier state. | Test that none is not a humidifier state. | async def test_state_with_none(hass):
"""Test that none is not a humidifier state."""
hass.states.async_set(ENTITY_1, STATE_OFF, {})
turn_on_calls = async_mock_service(hass, DOMAIN, SERVICE_TURN_ON)
turn_off_calls = async_mock_service(hass, DOMAIN, SERVICE_TURN_OFF)
mode_calls = async_mock_service(... | [
"async",
"def",
"test_state_with_none",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"ENTITY_1",
",",
"STATE_OFF",
",",
"{",
"}",
")",
"turn_on_calls",
"=",
"async_mock_service",
"(",
"hass",
",",
"DOMAIN",
",",
"SERVICE_TURN_ON",
")"... | [
165,
0
] | [
181,
35
] | python | en | ['en', 'en', 'en'] | True |
test_state_with_context | (hass) | Test that context is forwarded. | Test that context is forwarded. | async def test_state_with_context(hass):
"""Test that context is forwarded."""
hass.states.async_set(ENTITY_1, STATE_OFF, {})
turn_on_calls = async_mock_service(hass, DOMAIN, SERVICE_TURN_ON)
turn_off_calls = async_mock_service(hass, DOMAIN, SERVICE_TURN_OFF)
mode_calls = async_mock_service(hass, D... | [
"async",
"def",
"test_state_with_context",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"ENTITY_1",
",",
"STATE_OFF",
",",
"{",
"}",
")",
"turn_on_calls",
"=",
"async_mock_service",
"(",
"hass",
",",
"DOMAIN",
",",
"SERVICE_TURN_ON",
... | [
184,
0
] | [
212,
47
] | python | en | ['en', 'en', 'en'] | True |
test_attribute | (hass, service, attribute) | Test that service call is made for each attribute. | Test that service call is made for each attribute. | async def test_attribute(hass, service, attribute):
"""Test that service call is made for each attribute."""
hass.states.async_set(ENTITY_1, STATE_ON, {})
turn_on_calls = async_mock_service(hass, DOMAIN, SERVICE_TURN_ON)
turn_off_calls = async_mock_service(hass, DOMAIN, SERVICE_TURN_OFF)
calls_1 = ... | [
"async",
"def",
"test_attribute",
"(",
"hass",
",",
"service",
",",
"attribute",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"ENTITY_1",
",",
"STATE_ON",
",",
"{",
"}",
")",
"turn_on_calls",
"=",
"async_mock_service",
"(",
"hass",
",",
"DOMAIN"... | [
219,
0
] | [
236,
71
] | python | en | ['en', 'en', 'en'] | True |
_GlobalFreezeContext.__init__ | (self, manager: TimeoutManager) | Initialize internal timeout context manager. | Initialize internal timeout context manager. | def __init__(self, manager: TimeoutManager) -> None:
"""Initialize internal timeout context manager."""
self._loop: asyncio.AbstractEventLoop = asyncio.get_running_loop()
self._manager: TimeoutManager = manager | [
"def",
"__init__",
"(",
"self",
",",
"manager",
":",
"TimeoutManager",
")",
"->",
"None",
":",
"self",
".",
"_loop",
":",
"asyncio",
".",
"AbstractEventLoop",
"=",
"asyncio",
".",
"get_running_loop",
"(",
")",
"self",
".",
"_manager",
":",
"TimeoutManager",
... | [
29,
4
] | [
32,
47
] | python | en | ['en', 'en', 'en'] | True |
_GlobalFreezeContext._enter | (self) | Run freeze. | Run freeze. | def _enter(self) -> None:
"""Run freeze."""
if not self._manager.freezes_done:
return
# Global reset
for task in self._manager.global_tasks:
task.pause()
# Zones reset
for zone in self._manager.zones.values():
if not zone.freezes_done... | [
"def",
"_enter",
"(",
"self",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"_manager",
".",
"freezes_done",
":",
"return",
"# Global reset",
"for",
"task",
"in",
"self",
".",
"_manager",
".",
"global_tasks",
":",
"task",
".",
"pause",
"(",
")",
"#... | [
60,
4
] | [
75,
49
] | python | en | ['fr', 'eu', 'en'] | False |
_GlobalFreezeContext._exit | (self) | Finish freeze. | Finish freeze. | def _exit(self) -> None:
"""Finish freeze."""
self._manager.global_freezes.remove(self)
if not self._manager.freezes_done:
return
# Global reset
for task in self._manager.global_tasks:
task.reset()
# Zones reset
for zone in self._manager.... | [
"def",
"_exit",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_manager",
".",
"global_freezes",
".",
"remove",
"(",
"self",
")",
"if",
"not",
"self",
".",
"_manager",
".",
"freezes_done",
":",
"return",
"# Global reset",
"for",
"task",
"in",
"self",... | [
77,
4
] | [
91,
24
] | python | en | ['en', 'zu', 'en'] | False |
_ZoneFreezeContext.__init__ | (self, zone: _ZoneTimeoutManager) | Initialize internal timeout context manager. | Initialize internal timeout context manager. | def __init__(self, zone: _ZoneTimeoutManager) -> None:
"""Initialize internal timeout context manager."""
self._loop: asyncio.AbstractEventLoop = asyncio.get_running_loop()
self._zone: _ZoneTimeoutManager = zone | [
"def",
"__init__",
"(",
"self",
",",
"zone",
":",
"_ZoneTimeoutManager",
")",
"->",
"None",
":",
"self",
".",
"_loop",
":",
"asyncio",
".",
"AbstractEventLoop",
"=",
"asyncio",
".",
"get_running_loop",
"(",
")",
"self",
".",
"_zone",
":",
"_ZoneTimeoutManage... | [
97,
4
] | [
100,
46
] | python | en | ['en', 'en', 'en'] | True |
_ZoneFreezeContext._enter | (self) | Run freeze. | Run freeze. | def _enter(self) -> None:
"""Run freeze."""
if self._zone.freezes_done:
self._zone.pause()
self._zone.enter_freeze(self) | [
"def",
"_enter",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"_zone",
".",
"freezes_done",
":",
"self",
".",
"_zone",
".",
"pause",
"(",
")",
"self",
".",
"_zone",
".",
"enter_freeze",
"(",
"self",
")"
] | [
128,
4
] | [
132,
37
] | python | en | ['fr', 'eu', 'en'] | False |
_ZoneFreezeContext._exit | (self) | Finish freeze. | Finish freeze. | def _exit(self) -> None:
"""Finish freeze."""
self._zone.exit_freeze(self)
if not self._zone.freezes_done:
return
self._zone.reset() | [
"def",
"_exit",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_zone",
".",
"exit_freeze",
"(",
"self",
")",
"if",
"not",
"self",
".",
"_zone",
".",
"freezes_done",
":",
"return",
"self",
".",
"_zone",
".",
"reset",
"(",
")"
] | [
134,
4
] | [
139,
26
] | python | en | ['en', 'zu', 'en'] | False |
_GlobalTaskContext.__init__ | (
self,
manager: TimeoutManager,
task: asyncio.Task[Any],
timeout: float,
cool_down: float,
) | Initialize internal timeout context manager. | Initialize internal timeout context manager. | def __init__(
self,
manager: TimeoutManager,
task: asyncio.Task[Any],
timeout: float,
cool_down: float,
) -> None:
"""Initialize internal timeout context manager."""
self._loop: asyncio.AbstractEventLoop = asyncio.get_running_loop()
self._manager: Time... | [
"def",
"__init__",
"(",
"self",
",",
"manager",
":",
"TimeoutManager",
",",
"task",
":",
"asyncio",
".",
"Task",
"[",
"Any",
"]",
",",
"timeout",
":",
"float",
",",
"cool_down",
":",
"float",
",",
")",
"->",
"None",
":",
"self",
".",
"_loop",
":",
... | [
145,
4
] | [
161,
42
] | python | en | ['en', 'en', 'en'] | True |
_GlobalTaskContext.state | (self) | Return state of the Global task. | Return state of the Global task. | def state(self) -> _State:
"""Return state of the Global task."""
return self._state | [
"def",
"state",
"(",
"self",
")",
"->",
"_State",
":",
"return",
"self",
".",
"_state"
] | [
187,
4
] | [
189,
26
] | python | en | ['en', 'ig', 'en'] | True |
_GlobalTaskContext.zones_done_signal | (self) | Signal that all zones are done. | Signal that all zones are done. | def zones_done_signal(self) -> None:
"""Signal that all zones are done."""
self._wait_zone.set() | [
"def",
"zones_done_signal",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_wait_zone",
".",
"set",
"(",
")"
] | [
191,
4
] | [
193,
29
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.