body
stringlengths
26
98.2k
body_hash
int64
-9,222,864,604,528,158,000
9,221,803,474B
docstring
stringlengths
1
16.8k
path
stringlengths
5
230
name
stringlengths
1
96
repository_name
stringlengths
7
89
lang
stringclasses
1 value
body_without_docstring
stringlengths
20
98.2k
@property def response_code(self): '\n Gets the response_code of this UpdateHttpRedirectDetails.\n The response code returned for the redirect to the client. For more information, see `RFC 7231`__.\n\n __ https://tools.ietf.org/html/rfc7231#section-6.4\n\n\n :return: The response_code of...
-2,241,557,004,388,330,200
Gets the response_code of this UpdateHttpRedirectDetails. The response code returned for the redirect to the client. For more information, see `RFC 7231`__. __ https://tools.ietf.org/html/rfc7231#section-6.4 :return: The response_code of this UpdateHttpRedirectDetails. :rtype: int
darling_ansible/python_venv/lib/python3.7/site-packages/oci/waas/models/update_http_redirect_details.py
response_code
revnav/sandbox
python
@property def response_code(self): '\n Gets the response_code of this UpdateHttpRedirectDetails.\n The response code returned for the redirect to the client. For more information, see `RFC 7231`__.\n\n __ https://tools.ietf.org/html/rfc7231#section-6.4\n\n\n :return: The response_code of...
@response_code.setter def response_code(self, response_code): '\n Sets the response_code of this UpdateHttpRedirectDetails.\n The response code returned for the redirect to the client. For more information, see `RFC 7231`__.\n\n __ https://tools.ietf.org/html/rfc7231#section-6.4\n\n\n :p...
1,383,919,902,411,671,000
Sets the response_code of this UpdateHttpRedirectDetails. The response code returned for the redirect to the client. For more information, see `RFC 7231`__. __ https://tools.ietf.org/html/rfc7231#section-6.4 :param response_code: The response_code of this UpdateHttpRedirectDetails. :type: int
darling_ansible/python_venv/lib/python3.7/site-packages/oci/waas/models/update_http_redirect_details.py
response_code
revnav/sandbox
python
@response_code.setter def response_code(self, response_code): '\n Sets the response_code of this UpdateHttpRedirectDetails.\n The response code returned for the redirect to the client. For more information, see `RFC 7231`__.\n\n __ https://tools.ietf.org/html/rfc7231#section-6.4\n\n\n :p...
@property def freeform_tags(self): '\n Gets the freeform_tags of this UpdateHttpRedirectDetails.\n Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace.\n For more information, see `Resource Tags`__.\n\n Example: `{"Department"...
8,730,621,104,488,083,000
Gets the freeform_tags of this UpdateHttpRedirectDetails. Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see `Resource Tags`__. Example: `{"Department": "Finance"}` __ https://docs.cloud.oracle.com/Content/General/Concepts/resou...
darling_ansible/python_venv/lib/python3.7/site-packages/oci/waas/models/update_http_redirect_details.py
freeform_tags
revnav/sandbox
python
@property def freeform_tags(self): '\n Gets the freeform_tags of this UpdateHttpRedirectDetails.\n Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace.\n For more information, see `Resource Tags`__.\n\n Example: `{"Department"...
@freeform_tags.setter def freeform_tags(self, freeform_tags): '\n Sets the freeform_tags of this UpdateHttpRedirectDetails.\n Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace.\n For more information, see `Resource Tags`__.\n\n ...
-6,774,238,780,399,861,000
Sets the freeform_tags of this UpdateHttpRedirectDetails. Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see `Resource Tags`__. Example: `{"Department": "Finance"}` __ https://docs.cloud.oracle.com/Content/General/Concepts/resou...
darling_ansible/python_venv/lib/python3.7/site-packages/oci/waas/models/update_http_redirect_details.py
freeform_tags
revnav/sandbox
python
@freeform_tags.setter def freeform_tags(self, freeform_tags): '\n Sets the freeform_tags of this UpdateHttpRedirectDetails.\n Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace.\n For more information, see `Resource Tags`__.\n\n ...
@property def defined_tags(self): '\n Gets the defined_tags of this UpdateHttpRedirectDetails.\n Defined tags for this resource. Each key is predefined and scoped to a namespace.\n For more information, see `Resource Tags`__.\n\n Example: `{"Operations": {"CostCenter": "42"}}`\n\n ...
-2,485,616,187,404,974,600
Gets the defined_tags of this UpdateHttpRedirectDetails. Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see `Resource Tags`__. Example: `{"Operations": {"CostCenter": "42"}}` __ https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm :return: ...
darling_ansible/python_venv/lib/python3.7/site-packages/oci/waas/models/update_http_redirect_details.py
defined_tags
revnav/sandbox
python
@property def defined_tags(self): '\n Gets the defined_tags of this UpdateHttpRedirectDetails.\n Defined tags for this resource. Each key is predefined and scoped to a namespace.\n For more information, see `Resource Tags`__.\n\n Example: `{"Operations": {"CostCenter": "42"}}`\n\n ...
@defined_tags.setter def defined_tags(self, defined_tags): '\n Sets the defined_tags of this UpdateHttpRedirectDetails.\n Defined tags for this resource. Each key is predefined and scoped to a namespace.\n For more information, see `Resource Tags`__.\n\n Example: `{"Operations": {"CostCe...
651,850,713,821,746,700
Sets the defined_tags of this UpdateHttpRedirectDetails. Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see `Resource Tags`__. Example: `{"Operations": {"CostCenter": "42"}}` __ https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm :param de...
darling_ansible/python_venv/lib/python3.7/site-packages/oci/waas/models/update_http_redirect_details.py
defined_tags
revnav/sandbox
python
@defined_tags.setter def defined_tags(self, defined_tags): '\n Sets the defined_tags of this UpdateHttpRedirectDetails.\n Defined tags for this resource. Each key is predefined and scoped to a namespace.\n For more information, see `Resource Tags`__.\n\n Example: `{"Operations": {"CostCe...
def __call__(self, image, label): 'Call function of RandomMirrow_pair.\n\n :param image: usually the feature image, for example, the LR image for super solution dataset,\n the initial image for the segmentation dataset, and etc\n :type image: PIL image\n :param label: usually the label i...
1,972,414,202,479,548,700
Call function of RandomMirrow_pair. :param image: usually the feature image, for example, the LR image for super solution dataset, the initial image for the segmentation dataset, and etc :type image: PIL image :param label: usually the label image, for example, the HR image for super solution dataset, the mask image f...
vega/datasets/transforms/RandomMirrow_pair.py
__call__
NiuRc/vega
python
def __call__(self, image, label): 'Call function of RandomMirrow_pair.\n\n :param image: usually the feature image, for example, the LR image for super solution dataset,\n the initial image for the segmentation dataset, and etc\n :type image: PIL image\n :param label: usually the label i...
@classmethod def setup_class(cls): 'Setup the test class.' super().setup_class() cls._patch_logger() doc_path = os.path.join(ROOT_DIR, MD_FILE) cls.code_blocks = extract_code_blocks(filepath=doc_path, filter_='python') test_code_path = os.path.join(CUR_PATH, PY_FILE) cls.python_file = extrac...
-5,111,679,204,263,988,000
Setup the test class.
tests/test_docs/test_standalone_transaction/test_standalone_transaction.py
setup_class
valory-xyz/agents-aea
python
@classmethod def setup_class(cls): super().setup_class() cls._patch_logger() doc_path = os.path.join(ROOT_DIR, MD_FILE) cls.code_blocks = extract_code_blocks(filepath=doc_path, filter_='python') test_code_path = os.path.join(CUR_PATH, PY_FILE) cls.python_file = extract_python_code(test_code...
def test_read_md_file(self): 'Test the last code block, that is the full listing of the demo from the Markdown.' assert (self.code_blocks[(- 1)] == self.python_file), 'Files must be exactly the same.'
-1,915,740,591,947,311,900
Test the last code block, that is the full listing of the demo from the Markdown.
tests/test_docs/test_standalone_transaction/test_standalone_transaction.py
test_read_md_file
valory-xyz/agents-aea
python
def test_read_md_file(self): assert (self.code_blocks[(- 1)] == self.python_file), 'Files must be exactly the same.'
@pytest.mark.integration(reruns=MAX_FLAKY_RERUNS_INTEGRATION) def test_run_end_to_end(self): 'Run the transaction from the file.' try: run() self.mocked_logger_info.assert_any_call('Transaction complete.') except RuntimeError: test_logger.info('RuntimeError: Some transactions have fa...
6,095,263,727,091,250,000
Run the transaction from the file.
tests/test_docs/test_standalone_transaction/test_standalone_transaction.py
test_run_end_to_end
valory-xyz/agents-aea
python
@pytest.mark.integration(reruns=MAX_FLAKY_RERUNS_INTEGRATION) def test_run_end_to_end(self): try: run() self.mocked_logger_info.assert_any_call('Transaction complete.') except RuntimeError: test_logger.info('RuntimeError: Some transactions have failed')
def test_code_blocks_exist(self): 'Test that all the code-blocks exist in the python file.' for blocks in self.code_blocks: assert (blocks in self.python_file), "Code-block doesn't exist in the python file."
5,125,484,754,777,977,000
Test that all the code-blocks exist in the python file.
tests/test_docs/test_standalone_transaction/test_standalone_transaction.py
test_code_blocks_exist
valory-xyz/agents-aea
python
def test_code_blocks_exist(self): for blocks in self.code_blocks: assert (blocks in self.python_file), "Code-block doesn't exist in the python file."
@tf_export('PeriodicResample') def periodic_resample(values, shape, name=None): 'Periodically resample elements of a tensor to conform to `shape`.\n\n This function implements a slightly more generic version of the subpixel\n convolutions found in this [paper](https://arxiv.org/abs/1609.05158).\n\n The formula f...
377,029,510,498,402,050
Periodically resample elements of a tensor to conform to `shape`. This function implements a slightly more generic version of the subpixel convolutions found in this [paper](https://arxiv.org/abs/1609.05158). The formula for computing the elements in the `output` tensor is as follows: `T` = `values` tensor of rank ...
tensorflow/contrib/periodic_resample/python/ops/gen_periodic_resample_op.py
periodic_resample
gian1312/suchen
python
@tf_export('PeriodicResample') def periodic_resample(values, shape, name=None): 'Periodically resample elements of a tensor to conform to `shape`.\n\n This function implements a slightly more generic version of the subpixel\n convolutions found in this [paper](https://arxiv.org/abs/1609.05158).\n\n The formula f...
def encrypt(password): '\n Take a password string, encrypt it with Fernet symmetric encryption,\n and return the result (bytes), with the decryption key (bytes)\n ' encryption_key = Fernet.generate_key() fernet = Fernet(encryption_key) encrypted_password = fernet.encrypt(password.encode('utf-8'...
1,055,429,369,133,855,200
Take a password string, encrypt it with Fernet symmetric encryption, and return the result (bytes), with the decryption key (bytes)
snappass/main.py
encrypt
47Billion/snappass
python
def encrypt(password): '\n Take a password string, encrypt it with Fernet symmetric encryption,\n and return the result (bytes), with the decryption key (bytes)\n ' encryption_key = Fernet.generate_key() fernet = Fernet(encryption_key) encrypted_password = fernet.encrypt(password.encode('utf-8'...
def decrypt(password, decryption_key): '\n Decrypt a password (bytes) using the provided key (bytes),\n and return the plain-text password (bytes).\n ' fernet = Fernet(decryption_key) return fernet.decrypt(password)
4,633,125,073,615,073,000
Decrypt a password (bytes) using the provided key (bytes), and return the plain-text password (bytes).
snappass/main.py
decrypt
47Billion/snappass
python
def decrypt(password, decryption_key): '\n Decrypt a password (bytes) using the provided key (bytes),\n and return the plain-text password (bytes).\n ' fernet = Fernet(decryption_key) return fernet.decrypt(password)
@check_redis_alive def set_password(password, ttl): '\n Encrypt and store the password for the specified lifetime.\n\n Returns a token comprised of the key where the encrypted password\n is stored, and the decryption key.\n ' storage_key = (REDIS_PREFIX + uuid.uuid4().hex) (encrypted_password, e...
7,699,990,961,423,685,000
Encrypt and store the password for the specified lifetime. Returns a token comprised of the key where the encrypted password is stored, and the decryption key.
snappass/main.py
set_password
47Billion/snappass
python
@check_redis_alive def set_password(password, ttl): '\n Encrypt and store the password for the specified lifetime.\n\n Returns a token comprised of the key where the encrypted password\n is stored, and the decryption key.\n ' storage_key = (REDIS_PREFIX + uuid.uuid4().hex) (encrypted_password, e...
@check_redis_alive def get_password(token): '\n From a given token, return the initial password.\n\n If the token is tilde-separated, we decrypt the password fetched from Redis.\n If not, the password is simply returned as is.\n ' (storage_key, decryption_key) = parse_token(token) password = red...
7,419,285,449,449,767,000
From a given token, return the initial password. If the token is tilde-separated, we decrypt the password fetched from Redis. If not, the password is simply returned as is.
snappass/main.py
get_password
47Billion/snappass
python
@check_redis_alive def get_password(token): '\n From a given token, return the initial password.\n\n If the token is tilde-separated, we decrypt the password fetched from Redis.\n If not, the password is simply returned as is.\n ' (storage_key, decryption_key) = parse_token(token) password = red...
def clean_input(): "\n Make sure we're not getting bad data from the front end,\n format data to be machine readable\n " if empty(request.form.get('password', '')): abort(400) if empty(request.form.get('ttl', '')): abort(400) time_period = request.form['ttl'].lower() if (tim...
4,107,296,819,267,789,000
Make sure we're not getting bad data from the front end, format data to be machine readable
snappass/main.py
clean_input
47Billion/snappass
python
def clean_input(): "\n Make sure we're not getting bad data from the front end,\n format data to be machine readable\n " if empty(request.form.get('password', )): abort(400) if empty(request.form.get('ttl', )): abort(400) time_period = request.form['ttl'].lower() if (time_pe...
def prepare_to_disconnect(self) -> None: 'Called when we will disconnect with the peer.' pass
4,461,026,119,724,351,500
Called when we will disconnect with the peer.
hathor/p2p/states/base.py
prepare_to_disconnect
HathorNetwork/hathor-core
python
def prepare_to_disconnect(self) -> None: pass
def get_classes(dataset): 'Get class names of a dataset.' alias2name = {} for (name, aliases) in dataset_aliases.items(): for alias in aliases: alias2name[alias] = name if mmcv.is_str(dataset): if (dataset in alias2name): labels = eval((alias2name[dataset] + '_cla...
1,408,958,000,846,626,000
Get class names of a dataset.
my_configs/new/mmdet/core/evaluation/class_names.py
get_classes
UESTC-Liuxin/TianChi
python
def get_classes(dataset): alias2name = {} for (name, aliases) in dataset_aliases.items(): for alias in aliases: alias2name[alias] = name if mmcv.is_str(dataset): if (dataset in alias2name): labels = eval((alias2name[dataset] + '_classes()')) else: ...
def add_entities(self, devices, action): 'Mock add devices.' for device in devices: self.DEVICES.append(device)
436,858,714,708,463,360
Mock add devices.
tests/components/sensor/test_canary.py
add_entities
27tech/home-assistant
python
def add_entities(self, devices, action): for device in devices: self.DEVICES.append(device)
def setUp(self): 'Initialize values for this testcase class.' self.hass = get_test_home_assistant() self.config = copy.deepcopy(VALID_CONFIG)
1,489,049,775,505,830,400
Initialize values for this testcase class.
tests/components/sensor/test_canary.py
setUp
27tech/home-assistant
python
def setUp(self): self.hass = get_test_home_assistant() self.config = copy.deepcopy(VALID_CONFIG)
def tearDown(self): 'Stop everything that was started.' self.hass.stop()
8,876,712,114,682,698,000
Stop everything that was started.
tests/components/sensor/test_canary.py
tearDown
27tech/home-assistant
python
def tearDown(self): self.hass.stop()
def test_setup_sensors(self): 'Test the sensor setup.' online_device_at_home = mock_device(20, 'Dining Room', True, 'Canary') offline_device_at_home = mock_device(21, 'Front Yard', False, 'Canary') online_device_at_work = mock_device(22, 'Office', True, 'Canary') self.hass.data[DATA_CANARY] = Mock()...
5,771,754,367,131,772,000
Test the sensor setup.
tests/components/sensor/test_canary.py
test_setup_sensors
27tech/home-assistant
python
def test_setup_sensors(self): online_device_at_home = mock_device(20, 'Dining Room', True, 'Canary') offline_device_at_home = mock_device(21, 'Front Yard', False, 'Canary') online_device_at_work = mock_device(22, 'Office', True, 'Canary') self.hass.data[DATA_CANARY] = Mock() self.hass.data[DATA...
def test_temperature_sensor(self): 'Test temperature sensor with fahrenheit.' device = mock_device(10, 'Family Room', 'Canary') location = mock_location('Home', False) data = Mock() data.get_reading.return_value = 21.1234 sensor = CanarySensor(data, SENSOR_TYPES[0], location, device) sensor....
2,299,848,690,376,426,500
Test temperature sensor with fahrenheit.
tests/components/sensor/test_canary.py
test_temperature_sensor
27tech/home-assistant
python
def test_temperature_sensor(self): device = mock_device(10, 'Family Room', 'Canary') location = mock_location('Home', False) data = Mock() data.get_reading.return_value = 21.1234 sensor = CanarySensor(data, SENSOR_TYPES[0], location, device) sensor.update() assert ('Home Family Room Tem...
def test_temperature_sensor_with_none_sensor_value(self): 'Test temperature sensor with fahrenheit.' device = mock_device(10, 'Family Room', 'Canary') location = mock_location('Home', False) data = Mock() data.get_reading.return_value = None sensor = CanarySensor(data, SENSOR_TYPES[0], location,...
4,995,280,553,888,205,000
Test temperature sensor with fahrenheit.
tests/components/sensor/test_canary.py
test_temperature_sensor_with_none_sensor_value
27tech/home-assistant
python
def test_temperature_sensor_with_none_sensor_value(self): device = mock_device(10, 'Family Room', 'Canary') location = mock_location('Home', False) data = Mock() data.get_reading.return_value = None sensor = CanarySensor(data, SENSOR_TYPES[0], location, device) sensor.update() assert (s...
def test_humidity_sensor(self): 'Test humidity sensor.' device = mock_device(10, 'Family Room', 'Canary') location = mock_location('Home') data = Mock() data.get_reading.return_value = 50.4567 sensor = CanarySensor(data, SENSOR_TYPES[1], location, device) sensor.update() assert ('Home Fa...
845,884,128,519,718,300
Test humidity sensor.
tests/components/sensor/test_canary.py
test_humidity_sensor
27tech/home-assistant
python
def test_humidity_sensor(self): device = mock_device(10, 'Family Room', 'Canary') location = mock_location('Home') data = Mock() data.get_reading.return_value = 50.4567 sensor = CanarySensor(data, SENSOR_TYPES[1], location, device) sensor.update() assert ('Home Family Room Humidity' == ...
def test_air_quality_sensor_with_very_abnormal_reading(self): 'Test air quality sensor.' device = mock_device(10, 'Family Room', 'Canary') location = mock_location('Home') data = Mock() data.get_reading.return_value = 0.4 sensor = CanarySensor(data, SENSOR_TYPES[2], location, device) sensor....
1,296,633,011,677,636,000
Test air quality sensor.
tests/components/sensor/test_canary.py
test_air_quality_sensor_with_very_abnormal_reading
27tech/home-assistant
python
def test_air_quality_sensor_with_very_abnormal_reading(self): device = mock_device(10, 'Family Room', 'Canary') location = mock_location('Home') data = Mock() data.get_reading.return_value = 0.4 sensor = CanarySensor(data, SENSOR_TYPES[2], location, device) sensor.update() assert ('Home...
def test_air_quality_sensor_with_abnormal_reading(self): 'Test air quality sensor.' device = mock_device(10, 'Family Room', 'Canary') location = mock_location('Home') data = Mock() data.get_reading.return_value = 0.59 sensor = CanarySensor(data, SENSOR_TYPES[2], location, device) sensor.upda...
-5,240,649,530,815,184,000
Test air quality sensor.
tests/components/sensor/test_canary.py
test_air_quality_sensor_with_abnormal_reading
27tech/home-assistant
python
def test_air_quality_sensor_with_abnormal_reading(self): device = mock_device(10, 'Family Room', 'Canary') location = mock_location('Home') data = Mock() data.get_reading.return_value = 0.59 sensor = CanarySensor(data, SENSOR_TYPES[2], location, device) sensor.update() assert ('Home Fam...
def test_air_quality_sensor_with_normal_reading(self): 'Test air quality sensor.' device = mock_device(10, 'Family Room', 'Canary') location = mock_location('Home') data = Mock() data.get_reading.return_value = 1.0 sensor = CanarySensor(data, SENSOR_TYPES[2], location, device) sensor.update(...
-8,526,312,091,169,359,000
Test air quality sensor.
tests/components/sensor/test_canary.py
test_air_quality_sensor_with_normal_reading
27tech/home-assistant
python
def test_air_quality_sensor_with_normal_reading(self): device = mock_device(10, 'Family Room', 'Canary') location = mock_location('Home') data = Mock() data.get_reading.return_value = 1.0 sensor = CanarySensor(data, SENSOR_TYPES[2], location, device) sensor.update() assert ('Home Family...
def test_air_quality_sensor_with_none_sensor_value(self): 'Test air quality sensor.' device = mock_device(10, 'Family Room', 'Canary') location = mock_location('Home') data = Mock() data.get_reading.return_value = None sensor = CanarySensor(data, SENSOR_TYPES[2], location, device) sensor.upd...
2,885,458,907,634,710,000
Test air quality sensor.
tests/components/sensor/test_canary.py
test_air_quality_sensor_with_none_sensor_value
27tech/home-assistant
python
def test_air_quality_sensor_with_none_sensor_value(self): device = mock_device(10, 'Family Room', 'Canary') location = mock_location('Home') data = Mock() data.get_reading.return_value = None sensor = CanarySensor(data, SENSOR_TYPES[2], location, device) sensor.update() assert (sensor.s...
def test_battery_sensor(self): 'Test battery sensor.' device = mock_device(10, 'Family Room', 'Canary Flex') location = mock_location('Home') data = Mock() data.get_reading.return_value = 70.4567 sensor = CanarySensor(data, SENSOR_TYPES[4], location, device) sensor.update() assert ('Home...
-7,136,044,291,612,272,000
Test battery sensor.
tests/components/sensor/test_canary.py
test_battery_sensor
27tech/home-assistant
python
def test_battery_sensor(self): device = mock_device(10, 'Family Room', 'Canary Flex') location = mock_location('Home') data = Mock() data.get_reading.return_value = 70.4567 sensor = CanarySensor(data, SENSOR_TYPES[4], location, device) sensor.update() assert ('Home Family Room Battery' ...
def test_wifi_sensor(self): 'Test battery sensor.' device = mock_device(10, 'Family Room', 'Canary Flex') location = mock_location('Home') data = Mock() data.get_reading.return_value = (- 57) sensor = CanarySensor(data, SENSOR_TYPES[3], location, device) sensor.update() assert ('Home Fam...
6,827,206,662,562,437,000
Test battery sensor.
tests/components/sensor/test_canary.py
test_wifi_sensor
27tech/home-assistant
python
def test_wifi_sensor(self): device = mock_device(10, 'Family Room', 'Canary Flex') location = mock_location('Home') data = Mock() data.get_reading.return_value = (- 57) sensor = CanarySensor(data, SENSOR_TYPES[3], location, device) sensor.update() assert ('Home Family Room Wifi' == sens...
def lock_change_receiver(): '\n A decorator for connecting receivers to signals that a lock has change.\n\n @receiver(post_save, sender=MyModel)\n def signal_receiver(sender, **kwargs):\n ...\n\n ' def _decorator(func): LockCache.lock_change_receivers.append(func) ...
6,489,382,657,107,884,000
A decorator for connecting receivers to signals that a lock has change. @receiver(post_save, sender=MyModel) def signal_receiver(sender, **kwargs): ...
chroma_core/services/job_scheduler/lock_cache.py
lock_change_receiver
beevans/integrated-manager-for-lustre
python
def lock_change_receiver(): '\n A decorator for connecting receivers to signals that a lock has change.\n\n @receiver(post_save, sender=MyModel)\n def signal_receiver(sender, **kwargs):\n ...\n\n ' def _decorator(func): LockCache.lock_change_receivers.append(func) ...
@asyncio.coroutine def async_setup_platform(hass, config, async_add_entities, discovery_info=None): 'Setup the Kodi platform.' host = config.get(CONF_HOST) port = config.get(CONF_PORT) if (host.startswith('http://') or host.startswith('https://')): host = host.lstrip('http://').lstrip('https://'...
-8,385,398,847,880,551,000
Setup the Kodi platform.
homeassistant/components/media_player/kodi.py
async_setup_platform
sbidoul/home-assistant
python
@asyncio.coroutine def async_setup_platform(hass, config, async_add_entities, discovery_info=None): host = config.get(CONF_HOST) port = config.get(CONF_PORT) if (host.startswith('http://') or host.startswith('https://')): host = host.lstrip('http://').lstrip('https://') _LOGGER.warning(...
def __init__(self, hass, name, host, port, username=None, password=None, turn_off_action=None): 'Initialize the Kodi device.' import jsonrpc_async self.hass = hass self._name = name kwargs = {'timeout': DEFAULT_TIMEOUT, 'session': async_get_clientsession(hass)} if (username is not None): ...
52,345,360,531,689,720
Initialize the Kodi device.
homeassistant/components/media_player/kodi.py
__init__
sbidoul/home-assistant
python
def __init__(self, hass, name, host, port, username=None, password=None, turn_off_action=None): import jsonrpc_async self.hass = hass self._name = name kwargs = {'timeout': DEFAULT_TIMEOUT, 'session': async_get_clientsession(hass)} if (username is not None): kwargs['auth'] = aiohttp.Bas...
@property def name(self): 'Return the name of the device.' return self._name
-4,231,536,673,663,769,600
Return the name of the device.
homeassistant/components/media_player/kodi.py
name
sbidoul/home-assistant
python
@property def name(self): return self._name
@asyncio.coroutine def _get_players(self): 'Return the active player objects or None.' import jsonrpc_async try: return (yield from self._server.Player.GetActivePlayers()) except jsonrpc_async.jsonrpc.TransportError: if (self._players is not None): _LOGGER.info('Unable to fet...
2,476,486,676,554,726,000
Return the active player objects or None.
homeassistant/components/media_player/kodi.py
_get_players
sbidoul/home-assistant
python
@asyncio.coroutine def _get_players(self): import jsonrpc_async try: return (yield from self._server.Player.GetActivePlayers()) except jsonrpc_async.jsonrpc.TransportError: if (self._players is not None): _LOGGER.info('Unable to fetch kodi data') _LOGGER.debug('U...
@property def state(self): 'Return the state of the device.' if (self._players is None): return STATE_OFF if (len(self._players) == 0): return STATE_IDLE if ((self._properties['speed'] == 0) and (not self._properties['live'])): return STATE_PAUSED else: return STATE_P...
2,635,478,583,098,425,300
Return the state of the device.
homeassistant/components/media_player/kodi.py
state
sbidoul/home-assistant
python
@property def state(self): if (self._players is None): return STATE_OFF if (len(self._players) == 0): return STATE_IDLE if ((self._properties['speed'] == 0) and (not self._properties['live'])): return STATE_PAUSED else: return STATE_PLAYING
@asyncio.coroutine def async_update(self): 'Retrieve latest state.' self._players = (yield from self._get_players()) if ((self._players is not None) and (len(self._players) > 0)): player_id = self._players[0]['playerid'] assert isinstance(player_id, int) self._properties = (yield fro...
3,957,076,217,456,253,400
Retrieve latest state.
homeassistant/components/media_player/kodi.py
async_update
sbidoul/home-assistant
python
@asyncio.coroutine def async_update(self): self._players = (yield from self._get_players()) if ((self._players is not None) and (len(self._players) > 0)): player_id = self._players[0]['playerid'] assert isinstance(player_id, int) self._properties = (yield from self._server.Player.Ge...
@property def volume_level(self): 'Volume level of the media player (0..1).' if (self._app_properties is not None): return (self._app_properties['volume'] / 100.0)
-3,302,400,317,399,943,700
Volume level of the media player (0..1).
homeassistant/components/media_player/kodi.py
volume_level
sbidoul/home-assistant
python
@property def volume_level(self): if (self._app_properties is not None): return (self._app_properties['volume'] / 100.0)
@property def is_volume_muted(self): 'Boolean if volume is currently muted.' if (self._app_properties is not None): return self._app_properties['muted']
-8,554,226,172,136,375,000
Boolean if volume is currently muted.
homeassistant/components/media_player/kodi.py
is_volume_muted
sbidoul/home-assistant
python
@property def is_volume_muted(self): if (self._app_properties is not None): return self._app_properties['muted']
@property def media_content_id(self): 'Content ID of current playing media.' if (self._item is not None): return self._item.get('uniqueid', None)
595,466,316,143,477,800
Content ID of current playing media.
homeassistant/components/media_player/kodi.py
media_content_id
sbidoul/home-assistant
python
@property def media_content_id(self): if (self._item is not None): return self._item.get('uniqueid', None)
@property def media_content_type(self): 'Content type of current playing media.' if ((self._players is not None) and (len(self._players) > 0)): return self._players[0]['type']
5,483,545,840,153,864,000
Content type of current playing media.
homeassistant/components/media_player/kodi.py
media_content_type
sbidoul/home-assistant
python
@property def media_content_type(self): if ((self._players is not None) and (len(self._players) > 0)): return self._players[0]['type']
@property def media_duration(self): 'Duration of current playing media in seconds.' if ((self._properties is not None) and (not self._properties['live'])): total_time = self._properties['totaltime'] return (((total_time['hours'] * 3600) + (total_time['minutes'] * 60)) + total_time['seconds'])
5,925,154,130,673,134,000
Duration of current playing media in seconds.
homeassistant/components/media_player/kodi.py
media_duration
sbidoul/home-assistant
python
@property def media_duration(self): if ((self._properties is not None) and (not self._properties['live'])): total_time = self._properties['totaltime'] return (((total_time['hours'] * 3600) + (total_time['minutes'] * 60)) + total_time['seconds'])
@property def media_image_url(self): 'Image url of current playing media.' if (self._item is None): return None url_components = urllib.parse.urlparse(self._item['thumbnail']) if (url_components.scheme == 'image'): return '{}/{}'.format(self._image_url, urllib.parse.quote_plus(self._item...
-1,714,821,105,424,071,200
Image url of current playing media.
homeassistant/components/media_player/kodi.py
media_image_url
sbidoul/home-assistant
python
@property def media_image_url(self): if (self._item is None): return None url_components = urllib.parse.urlparse(self._item['thumbnail']) if (url_components.scheme == 'image'): return '{}/{}'.format(self._image_url, urllib.parse.quote_plus(self._item['thumbnail']))
@property def media_title(self): 'Title of current playing media.' if (self._item is not None): return self._item.get('title', self._item.get('label', self._item.get('file', 'unknown')))
-5,467,127,369,238,786,000
Title of current playing media.
homeassistant/components/media_player/kodi.py
media_title
sbidoul/home-assistant
python
@property def media_title(self): if (self._item is not None): return self._item.get('title', self._item.get('label', self._item.get('file', 'unknown')))
@property def supported_media_commands(self): 'Flag of media commands that are supported.' supported_media_commands = SUPPORT_KODI if (self._turn_off_action in TURN_OFF_ACTION): supported_media_commands |= SUPPORT_TURN_OFF return supported_media_commands
-2,403,220,702,515,875,300
Flag of media commands that are supported.
homeassistant/components/media_player/kodi.py
supported_media_commands
sbidoul/home-assistant
python
@property def supported_media_commands(self): supported_media_commands = SUPPORT_KODI if (self._turn_off_action in TURN_OFF_ACTION): supported_media_commands |= SUPPORT_TURN_OFF return supported_media_commands
@asyncio.coroutine def async_turn_off(self): 'Execute turn_off_action to turn off media player.' if (self._turn_off_action == 'quit'): (yield from self._server.Application.Quit()) elif (self._turn_off_action == 'hibernate'): (yield from self._server.System.Hibernate()) elif (self._turn_o...
4,009,115,081,220,730,400
Execute turn_off_action to turn off media player.
homeassistant/components/media_player/kodi.py
async_turn_off
sbidoul/home-assistant
python
@asyncio.coroutine def async_turn_off(self): if (self._turn_off_action == 'quit'): (yield from self._server.Application.Quit()) elif (self._turn_off_action == 'hibernate'): (yield from self._server.System.Hibernate()) elif (self._turn_off_action == 'suspend'): (yield from self._...
@asyncio.coroutine def async_volume_up(self): 'Volume up the media player.' assert ((yield from self._server.Input.ExecuteAction('volumeup')) == 'OK')
3,553,895,284,560,768,500
Volume up the media player.
homeassistant/components/media_player/kodi.py
async_volume_up
sbidoul/home-assistant
python
@asyncio.coroutine def async_volume_up(self): assert ((yield from self._server.Input.ExecuteAction('volumeup')) == 'OK')
@asyncio.coroutine def async_volume_down(self): 'Volume down the media player.' assert ((yield from self._server.Input.ExecuteAction('volumedown')) == 'OK')
-4,431,140,225,079,229,400
Volume down the media player.
homeassistant/components/media_player/kodi.py
async_volume_down
sbidoul/home-assistant
python
@asyncio.coroutine def async_volume_down(self): assert ((yield from self._server.Input.ExecuteAction('volumedown')) == 'OK')
def async_set_volume_level(self, volume): 'Set volume level, range 0..1.\n\n This method must be run in the event loop and returns a coroutine.\n ' return self._server.Application.SetVolume(int((volume * 100)))
8,457,646,432,285,553,000
Set volume level, range 0..1. This method must be run in the event loop and returns a coroutine.
homeassistant/components/media_player/kodi.py
async_set_volume_level
sbidoul/home-assistant
python
def async_set_volume_level(self, volume): 'Set volume level, range 0..1.\n\n This method must be run in the event loop and returns a coroutine.\n ' return self._server.Application.SetVolume(int((volume * 100)))
def async_mute_volume(self, mute): 'Mute (true) or unmute (false) media player.\n\n This method must be run in the event loop and returns a coroutine.\n ' return self._server.Application.SetMute(mute)
97,019,771,065,311,620
Mute (true) or unmute (false) media player. This method must be run in the event loop and returns a coroutine.
homeassistant/components/media_player/kodi.py
async_mute_volume
sbidoul/home-assistant
python
def async_mute_volume(self, mute): 'Mute (true) or unmute (false) media player.\n\n This method must be run in the event loop and returns a coroutine.\n ' return self._server.Application.SetMute(mute)
@asyncio.coroutine def async_set_play_state(self, state): 'Helper method for play/pause/toggle.' players = (yield from self._get_players()) if (len(players) != 0): (yield from self._server.Player.PlayPause(players[0]['playerid'], state))
6,011,301,021,335,337,000
Helper method for play/pause/toggle.
homeassistant/components/media_player/kodi.py
async_set_play_state
sbidoul/home-assistant
python
@asyncio.coroutine def async_set_play_state(self, state): players = (yield from self._get_players()) if (len(players) != 0): (yield from self._server.Player.PlayPause(players[0]['playerid'], state))
def async_media_play_pause(self): 'Pause media on media player.\n\n This method must be run in the event loop and returns a coroutine.\n ' return self.async_set_play_state('toggle')
-7,341,939,771,844,527,000
Pause media on media player. This method must be run in the event loop and returns a coroutine.
homeassistant/components/media_player/kodi.py
async_media_play_pause
sbidoul/home-assistant
python
def async_media_play_pause(self): 'Pause media on media player.\n\n This method must be run in the event loop and returns a coroutine.\n ' return self.async_set_play_state('toggle')
def async_media_play(self): 'Play media.\n\n This method must be run in the event loop and returns a coroutine.\n ' return self.async_set_play_state(True)
-2,520,068,111,156,763,600
Play media. This method must be run in the event loop and returns a coroutine.
homeassistant/components/media_player/kodi.py
async_media_play
sbidoul/home-assistant
python
def async_media_play(self): 'Play media.\n\n This method must be run in the event loop and returns a coroutine.\n ' return self.async_set_play_state(True)
def async_media_pause(self): 'Pause the media player.\n\n This method must be run in the event loop and returns a coroutine.\n ' return self.async_set_play_state(False)
6,682,939,788,905,580,000
Pause the media player. This method must be run in the event loop and returns a coroutine.
homeassistant/components/media_player/kodi.py
async_media_pause
sbidoul/home-assistant
python
def async_media_pause(self): 'Pause the media player.\n\n This method must be run in the event loop and returns a coroutine.\n ' return self.async_set_play_state(False)
@asyncio.coroutine def async_media_stop(self): 'Stop the media player.' players = (yield from self._get_players()) if (len(players) != 0): (yield from self._server.Player.Stop(players[0]['playerid']))
-6,347,300,543,494,530,000
Stop the media player.
homeassistant/components/media_player/kodi.py
async_media_stop
sbidoul/home-assistant
python
@asyncio.coroutine def async_media_stop(self): players = (yield from self._get_players()) if (len(players) != 0): (yield from self._server.Player.Stop(players[0]['playerid']))
@asyncio.coroutine def _goto(self, direction): 'Helper method used for previous/next track.' players = (yield from self._get_players()) if (len(players) != 0): if (direction == 'previous'): (yield from self._server.Player.Seek(players[0]['playerid'], 0)) (yield from self._server....
-3,141,966,149,428,018,700
Helper method used for previous/next track.
homeassistant/components/media_player/kodi.py
_goto
sbidoul/home-assistant
python
@asyncio.coroutine def _goto(self, direction): players = (yield from self._get_players()) if (len(players) != 0): if (direction == 'previous'): (yield from self._server.Player.Seek(players[0]['playerid'], 0)) (yield from self._server.Player.GoTo(players[0]['playerid'], direction...
def async_media_next_track(self): 'Send next track command.\n\n This method must be run in the event loop and returns a coroutine.\n ' return self._goto('next')
4,079,830,510,610,262,000
Send next track command. This method must be run in the event loop and returns a coroutine.
homeassistant/components/media_player/kodi.py
async_media_next_track
sbidoul/home-assistant
python
def async_media_next_track(self): 'Send next track command.\n\n This method must be run in the event loop and returns a coroutine.\n ' return self._goto('next')
def async_media_previous_track(self): 'Send next track command.\n\n This method must be run in the event loop and returns a coroutine.\n ' return self._goto('previous')
-763,769,962,323,606,400
Send next track command. This method must be run in the event loop and returns a coroutine.
homeassistant/components/media_player/kodi.py
async_media_previous_track
sbidoul/home-assistant
python
def async_media_previous_track(self): 'Send next track command.\n\n This method must be run in the event loop and returns a coroutine.\n ' return self._goto('previous')
@asyncio.coroutine def async_media_seek(self, position): 'Send seek command.' players = (yield from self._get_players()) time = {} time['milliseconds'] = int(((position % 1) * 1000)) position = int(position) time['seconds'] = int((position % 60)) position /= 60 time['minutes'] = int((pos...
-2,504,506,522,176,259,600
Send seek command.
homeassistant/components/media_player/kodi.py
async_media_seek
sbidoul/home-assistant
python
@asyncio.coroutine def async_media_seek(self, position): players = (yield from self._get_players()) time = {} time['milliseconds'] = int(((position % 1) * 1000)) position = int(position) time['seconds'] = int((position % 60)) position /= 60 time['minutes'] = int((position % 60)) pos...
def async_play_media(self, media_type, media_id, **kwargs): 'Send the play_media command to the media player.\n\n This method must be run in the event loop and returns a coroutine.\n ' if (media_type == 'CHANNEL'): return self._server.Player.Open({'item': {'channelid': int(media_id)}}) ...
1,485,067,972,021,763,000
Send the play_media command to the media player. This method must be run in the event loop and returns a coroutine.
homeassistant/components/media_player/kodi.py
async_play_media
sbidoul/home-assistant
python
def async_play_media(self, media_type, media_id, **kwargs): 'Send the play_media command to the media player.\n\n This method must be run in the event loop and returns a coroutine.\n ' if (media_type == 'CHANNEL'): return self._server.Player.Open({'item': {'channelid': int(media_id)}}) ...
def gradients(output_node, node_list, scheduler_policy=None): 'Take gradient of output node with respect to each node in node_list.\n\n Parameters\n ----------\n output_node: output node that we are taking derivative of.\n node_list: list of nodes that we are taking derivative wrt.\n\n Returns\n -...
-7,271,513,188,193,601,000
Take gradient of output node with respect to each node in node_list. Parameters ---------- output_node: output node that we are taking derivative of. node_list: list of nodes that we are taking derivative wrt. Returns ------- A list of gradient values, one for each node in node_list respectively.
python/athena/gpu_ops/StreamExecutor.py
gradients
DMALab/TSplit
python
def gradients(output_node, node_list, scheduler_policy=None): 'Take gradient of output node with respect to each node in node_list.\n\n Parameters\n ----------\n output_node: output node that we are taking derivative of.\n node_list: list of nodes that we are taking derivative wrt.\n\n Returns\n -...
def distributed_gradients(output_node, node_list, scheduler_policy=None): 'Take gradient of output node with respect to each node in node_list.\n\n Parameters\n ----------\n output_node: output node that we are taking derivative of.\n node_list: list of nodes that we are taking derivative wrt.\n\n Re...
-8,072,602,044,061,928,000
Take gradient of output node with respect to each node in node_list. Parameters ---------- output_node: output node that we are taking derivative of. node_list: list of nodes that we are taking derivative wrt. Returns ------- A list of gradient values, one for each node in node_list respectively.
python/athena/gpu_ops/StreamExecutor.py
distributed_gradients
DMALab/TSplit
python
def distributed_gradients(output_node, node_list, scheduler_policy=None): 'Take gradient of output node with respect to each node in node_list.\n\n Parameters\n ----------\n output_node: output node that we are taking derivative of.\n node_list: list of nodes that we are taking derivative wrt.\n\n Re...
def find_topo_sort(node_list): 'Given a list of nodes, return a topo ordering of nodes ending in them.\n\n A simple algorithm is to do a post-order DFS traversal on the given nodes,\n going backwards based on input edges. Since a node is added to the ordering\n after all its predecessors are traversed due ...
-6,221,163,888,668,146,000
Given a list of nodes, return a topo ordering of nodes ending in them. A simple algorithm is to do a post-order DFS traversal on the given nodes, going backwards based on input edges. Since a node is added to the ordering after all its predecessors are traversed due to post-order DFS, we get a topological sort.
python/athena/gpu_ops/StreamExecutor.py
find_topo_sort
DMALab/TSplit
python
def find_topo_sort(node_list): 'Given a list of nodes, return a topo ordering of nodes ending in them.\n\n A simple algorithm is to do a post-order DFS traversal on the given nodes,\n going backwards based on input edges. Since a node is added to the ordering\n after all its predecessors are traversed due ...
def topo_sort_dfs(node, visited, topo_order): 'Post-order DFS' if (node in visited): return visited.add(node) for n in node.inputs: topo_sort_dfs(n, visited, topo_order) topo_order.append(node)
-1,676,523,686,901,708,000
Post-order DFS
python/athena/gpu_ops/StreamExecutor.py
topo_sort_dfs
DMALab/TSplit
python
def topo_sort_dfs(node, visited, topo_order): if (node in visited): return visited.add(node) for n in node.inputs: topo_sort_dfs(n, visited, topo_order) topo_order.append(node)
def sum_node_list(node_list): 'Custom sum func to avoid creating redundant nodes in Python sum func.' from operator import add from functools import reduce return reduce(add, node_list)
-2,496,900,066,984,713,700
Custom sum func to avoid creating redundant nodes in Python sum func.
python/athena/gpu_ops/StreamExecutor.py
sum_node_list
DMALab/TSplit
python
def sum_node_list(node_list): from operator import add from functools import reduce return reduce(add, node_list)
def broadcast_rule(shape_a, shape_b): 'Return output shape of broadcast shape_a, shape_b.\n e.g. broadcast_rule((3,2), (4,3,2))\n returns output_shape = (4,3,2)\n\n Check out explanations and more examples at\n https://docs.scipy.org/doc/numpy-1.10.0/user/basics.broadcasting.html\n http://eli.thegree...
-5,697,759,041,333,517,000
Return output shape of broadcast shape_a, shape_b. e.g. broadcast_rule((3,2), (4,3,2)) returns output_shape = (4,3,2) Check out explanations and more examples at https://docs.scipy.org/doc/numpy-1.10.0/user/basics.broadcasting.html http://eli.thegreenplace.net/2015/broadcasting-arrays-in-numpy/
python/athena/gpu_ops/StreamExecutor.py
broadcast_rule
DMALab/TSplit
python
def broadcast_rule(shape_a, shape_b): 'Return output shape of broadcast shape_a, shape_b.\n e.g. broadcast_rule((3,2), (4,3,2))\n returns output_shape = (4,3,2)\n\n Check out explanations and more examples at\n https://docs.scipy.org/doc/numpy-1.10.0/user/basics.broadcasting.html\n http://eli.thegree...
def __init__(self, eval_node_list, ctx=None, stream=None, policy=None): '\n Parameters\n ----------\n eval_node_list: list of nodes whose values need to be computed.\n ctx: runtime DLContext, default is None which means np.ndarray on cpu\n topo_order: list of nodes in topological ...
6,018,590,634,589,362,000
Parameters ---------- eval_node_list: list of nodes whose values need to be computed. ctx: runtime DLContext, default is None which means np.ndarray on cpu topo_order: list of nodes in topological order node_to_shape_map: dict from node to shape of the node node_to_arr_map: dict from node to ndarray.NDArray allocated f...
python/athena/gpu_ops/StreamExecutor.py
__init__
DMALab/TSplit
python
def __init__(self, eval_node_list, ctx=None, stream=None, policy=None): '\n Parameters\n ----------\n eval_node_list: list of nodes whose values need to be computed.\n ctx: runtime DLContext, default is None which means np.ndarray on cpu\n topo_order: list of nodes in topological ...
def infer_shape(self, feed_shapes): 'Given shapes of feed_dict nodes, infer shape for all nodes in graph.\n\n Implementation note:\n Iteratively calls node.op.infer_shape to infer shapes.\n Node shapes stored in self.node_to_shape_map.\n\n Parameters\n ----------\n feed_sha...
7,062,469,075,092,815,000
Given shapes of feed_dict nodes, infer shape for all nodes in graph. Implementation note: Iteratively calls node.op.infer_shape to infer shapes. Node shapes stored in self.node_to_shape_map. Parameters ---------- feed_shapes: node->shapes mapping for feed_dict nodes.
python/athena/gpu_ops/StreamExecutor.py
infer_shape
DMALab/TSplit
python
def infer_shape(self, feed_shapes): 'Given shapes of feed_dict nodes, infer shape for all nodes in graph.\n\n Implementation note:\n Iteratively calls node.op.infer_shape to infer shapes.\n Node shapes stored in self.node_to_shape_map.\n\n Parameters\n ----------\n feed_sha...
def memory_plan(self, feed_shapes): 'Allocates ndarray.NDArray for every node except feed_dict nodes.\n\n Implementation note:\n Option 1: Alloc a ndarray.NDArray per node that persists across run()\n Option 2: Implement a memory pool to reuse memory for nodes of same\n shapes. M...
4,789,048,243,198,603,000
Allocates ndarray.NDArray for every node except feed_dict nodes. Implementation note: Option 1: Alloc a ndarray.NDArray per node that persists across run() Option 2: Implement a memory pool to reuse memory for nodes of same shapes. More details see Lecture 7. For both options, self.node_to_arr_map stores node...
python/athena/gpu_ops/StreamExecutor.py
memory_plan
DMALab/TSplit
python
def memory_plan(self, feed_shapes): 'Allocates ndarray.NDArray for every node except feed_dict nodes.\n\n Implementation note:\n Option 1: Alloc a ndarray.NDArray per node that persists across run()\n Option 2: Implement a memory pool to reuse memory for nodes of same\n shapes. M...
def run(self, feed_dict, convert_to_numpy_ret_vals=False): '\n Parameters\n ----------\n feed_dict: a dictionary of node->np.ndarray supplied by user.\n convert_to_numpy_ret_vals: whether to convert ret vals to np.array\n\n Returns\n -------\n A list of values for no...
2,019,878,336,962,382,000
Parameters ---------- feed_dict: a dictionary of node->np.ndarray supplied by user. convert_to_numpy_ret_vals: whether to convert ret vals to np.array Returns ------- A list of values for nodes in eval_node_list. NDArray or np.ndarray.
python/athena/gpu_ops/StreamExecutor.py
run
DMALab/TSplit
python
def run(self, feed_dict, convert_to_numpy_ret_vals=False): '\n Parameters\n ----------\n feed_dict: a dictionary of node->np.ndarray supplied by user.\n convert_to_numpy_ret_vals: whether to convert ret vals to np.array\n\n Returns\n -------\n A list of values for no...
@inlineCallbacks def _callback(self): '\n This will be called repeatedly every `self.interval` seconds.\n `self.subscriptions` contain tuples of (obj, args, kwargs) for\n each subscribing object.\n\n If overloading, this callback is expected to handle all\n subscriptions when it i...
-6,995,095,253,856,614,000
This will be called repeatedly every `self.interval` seconds. `self.subscriptions` contain tuples of (obj, args, kwargs) for each subscribing object. If overloading, this callback is expected to handle all subscriptions when it is triggered. It should not return anything and should not traceback on poorly designed hoo...
evennia/scripts/tickerhandler.py
_callback
orkim/evennia
python
@inlineCallbacks def _callback(self): '\n This will be called repeatedly every `self.interval` seconds.\n `self.subscriptions` contain tuples of (obj, args, kwargs) for\n each subscribing object.\n\n If overloading, this callback is expected to handle all\n subscriptions when it i...
def __init__(self, interval): '\n Set up the ticker\n\n Args:\n interval (int): The stepping interval.\n\n ' self.interval = interval self.subscriptions = {} self._is_ticking = False self._to_remove = [] self._to_add = [] self.task = ExtendedLoopingCall(self._...
-8,686,783,412,515,952,000
Set up the ticker Args: interval (int): The stepping interval.
evennia/scripts/tickerhandler.py
__init__
orkim/evennia
python
def __init__(self, interval): '\n Set up the ticker\n\n Args:\n interval (int): The stepping interval.\n\n ' self.interval = interval self.subscriptions = {} self._is_ticking = False self._to_remove = [] self._to_add = [] self.task = ExtendedLoopingCall(self._...
def validate(self, start_delay=None): '\n Start/stop the task depending on how many subscribers we have\n using it.\n\n Args:\n start_delay (int): Time to way before starting.\n\n ' subs = self.subscriptions if self.task.running: if (not subs): self...
-7,546,078,601,667,794,000
Start/stop the task depending on how many subscribers we have using it. Args: start_delay (int): Time to way before starting.
evennia/scripts/tickerhandler.py
validate
orkim/evennia
python
def validate(self, start_delay=None): '\n Start/stop the task depending on how many subscribers we have\n using it.\n\n Args:\n start_delay (int): Time to way before starting.\n\n ' subs = self.subscriptions if self.task.running: if (not subs): self...
def add(self, store_key, *args, **kwargs): '\n Sign up a subscriber to this ticker.\n Args:\n store_key (str): Unique storage hash for this ticker subscription.\n args (any, optional): Arguments to call the hook method with.\n\n Kwargs:\n _start_delay (int): If ...
-7,771,333,856,930,565,000
Sign up a subscriber to this ticker. Args: store_key (str): Unique storage hash for this ticker subscription. args (any, optional): Arguments to call the hook method with. Kwargs: _start_delay (int): If set, this will be used to delay the start of the trigger instead of `interval`.
evennia/scripts/tickerhandler.py
add
orkim/evennia
python
def add(self, store_key, *args, **kwargs): '\n Sign up a subscriber to this ticker.\n Args:\n store_key (str): Unique storage hash for this ticker subscription.\n args (any, optional): Arguments to call the hook method with.\n\n Kwargs:\n _start_delay (int): If ...
def remove(self, store_key): '\n Unsubscribe object from this ticker\n\n Args:\n store_key (str): Unique store key.\n\n ' if self._is_ticking: self._to_remove.append(store_key) else: self.subscriptions.pop(store_key, False) self.validate()
5,622,023,714,555,823,000
Unsubscribe object from this ticker Args: store_key (str): Unique store key.
evennia/scripts/tickerhandler.py
remove
orkim/evennia
python
def remove(self, store_key): '\n Unsubscribe object from this ticker\n\n Args:\n store_key (str): Unique store key.\n\n ' if self._is_ticking: self._to_remove.append(store_key) else: self.subscriptions.pop(store_key, False) self.validate()
def stop(self): '\n Kill the Task, regardless of subscriptions.\n\n ' self.subscriptions = {} self.validate()
-9,085,155,564,099,422,000
Kill the Task, regardless of subscriptions.
evennia/scripts/tickerhandler.py
stop
orkim/evennia
python
def stop(self): '\n \n\n ' self.subscriptions = {} self.validate()
def __init__(self): '\n Initialize the pool.\n\n ' self.tickers = {}
3,492,824,550,037,405,000
Initialize the pool.
evennia/scripts/tickerhandler.py
__init__
orkim/evennia
python
def __init__(self): '\n \n\n ' self.tickers = {}
def add(self, store_key, *args, **kwargs): '\n Add new ticker subscriber.\n\n Args:\n store_key (str): Unique storage hash.\n args (any, optional): Arguments to send to the hook method.\n\n ' (_, _, _, interval, _, _) = store_key if (not interval): log_err(...
-1,308,441,702,683,874,800
Add new ticker subscriber. Args: store_key (str): Unique storage hash. args (any, optional): Arguments to send to the hook method.
evennia/scripts/tickerhandler.py
add
orkim/evennia
python
def add(self, store_key, *args, **kwargs): '\n Add new ticker subscriber.\n\n Args:\n store_key (str): Unique storage hash.\n args (any, optional): Arguments to send to the hook method.\n\n ' (_, _, _, interval, _, _) = store_key if (not interval): log_err(...
def remove(self, store_key): '\n Remove subscription from pool.\n\n Args:\n store_key (str): Unique storage hash to remove\n\n ' (_, _, _, interval, _, _) = store_key if (interval in self.tickers): self.tickers[interval].remove(store_key) if (not self.tickers[...
5,483,067,318,597,050,000
Remove subscription from pool. Args: store_key (str): Unique storage hash to remove
evennia/scripts/tickerhandler.py
remove
orkim/evennia
python
def remove(self, store_key): '\n Remove subscription from pool.\n\n Args:\n store_key (str): Unique storage hash to remove\n\n ' (_, _, _, interval, _, _) = store_key if (interval in self.tickers): self.tickers[interval].remove(store_key) if (not self.tickers[...
def stop(self, interval=None): '\n Stop all scripts in pool. This is done at server reload since\n restoring the pool will automatically re-populate the pool.\n\n Args:\n interval (int, optional): Only stop tickers with this\n interval.\n\n ' if (interval an...
-8,835,157,636,026,703,000
Stop all scripts in pool. This is done at server reload since restoring the pool will automatically re-populate the pool. Args: interval (int, optional): Only stop tickers with this interval.
evennia/scripts/tickerhandler.py
stop
orkim/evennia
python
def stop(self, interval=None): '\n Stop all scripts in pool. This is done at server reload since\n restoring the pool will automatically re-populate the pool.\n\n Args:\n interval (int, optional): Only stop tickers with this\n interval.\n\n ' if (interval an...
def __init__(self, save_name='ticker_storage'): '\n Initialize handler\n\n save_name (str, optional): The name of the ServerConfig\n instance to store the handler state persistently.\n\n ' self.ticker_storage = {} self.save_name = save_name self.ticker_pool = self.ticker_...
8,811,394,493,094,823,000
Initialize handler save_name (str, optional): The name of the ServerConfig instance to store the handler state persistently.
evennia/scripts/tickerhandler.py
__init__
orkim/evennia
python
def __init__(self, save_name='ticker_storage'): '\n Initialize handler\n\n save_name (str, optional): The name of the ServerConfig\n instance to store the handler state persistently.\n\n ' self.ticker_storage = {} self.save_name = save_name self.ticker_pool = self.ticker_...
def _get_callback(self, callback): "\n Analyze callback and determine its consituents\n\n Args:\n callback (function or method): This is either a stand-alone\n function or class method on a typeclassed entitye (that is,\n an entity that can be saved to the data...
-7,416,390,526,428,229,000
Analyze callback and determine its consituents Args: callback (function or method): This is either a stand-alone function or class method on a typeclassed entitye (that is, an entity that can be saved to the database). Returns: ret (tuple): This is a tuple of the form `(obj, path, callfunc)`, ...
evennia/scripts/tickerhandler.py
_get_callback
orkim/evennia
python
def _get_callback(self, callback): "\n Analyze callback and determine its consituents\n\n Args:\n callback (function or method): This is either a stand-alone\n function or class method on a typeclassed entitye (that is,\n an entity that can be saved to the data...
def _store_key(self, obj, path, interval, callfunc, idstring='', persistent=True): '\n Tries to create a store_key for the object.\n\n Args:\n obj (Object, tuple or None): Subscribing object if any. If a tuple, this is\n a packed_obj tuple from dbserialize.\n path ...
6,292,473,907,682,195,000
Tries to create a store_key for the object. Args: obj (Object, tuple or None): Subscribing object if any. If a tuple, this is a packed_obj tuple from dbserialize. path (str or None): Python-path to callable, if any. interval (int): Ticker interval. callfunc (callable or str): This is either the...
evennia/scripts/tickerhandler.py
_store_key
orkim/evennia
python
def _store_key(self, obj, path, interval, callfunc, idstring=, persistent=True): '\n Tries to create a store_key for the object.\n\n Args:\n obj (Object, tuple or None): Subscribing object if any. If a tuple, this is\n a packed_obj tuple from dbserialize.\n path (s...
def save(self): '\n Save ticker_storage as a serialized string into a temporary\n ServerConf field. Whereas saving is done on the fly, if called\n by server when it shuts down, the current timer of each ticker\n will be saved so it can start over from that point.\n\n ' if self...
-2,642,650,010,556,636,700
Save ticker_storage as a serialized string into a temporary ServerConf field. Whereas saving is done on the fly, if called by server when it shuts down, the current timer of each ticker will be saved so it can start over from that point.
evennia/scripts/tickerhandler.py
save
orkim/evennia
python
def save(self): '\n Save ticker_storage as a serialized string into a temporary\n ServerConf field. Whereas saving is done on the fly, if called\n by server when it shuts down, the current timer of each ticker\n will be saved so it can start over from that point.\n\n ' if self...
def restore(self, server_reload=True): '\n Restore ticker_storage from database and re-initialize the\n handler from storage. This is triggered by the server at\n restart.\n\n Args:\n server_reload (bool, optional): If this is False, it means\n the server went t...
4,263,887,369,786,780,700
Restore ticker_storage from database and re-initialize the handler from storage. This is triggered by the server at restart. Args: server_reload (bool, optional): If this is False, it means the server went through a cold reboot and all non-persistent tickers must be killed.
evennia/scripts/tickerhandler.py
restore
orkim/evennia
python
def restore(self, server_reload=True): '\n Restore ticker_storage from database and re-initialize the\n handler from storage. This is triggered by the server at\n restart.\n\n Args:\n server_reload (bool, optional): If this is False, it means\n the server went t...
def add(self, interval=60, callback=None, idstring='', persistent=True, *args, **kwargs): '\n Add subscription to tickerhandler\n\n Args:\n interval (int, optional): Interval in seconds between calling\n `callable(*args, **kwargs)`\n callable (callable function or ...
-9,201,289,920,555,109,000
Add subscription to tickerhandler Args: interval (int, optional): Interval in seconds between calling `callable(*args, **kwargs)` callable (callable function or method, optional): This should either be a stand-alone function or a method on a typeclassed entity (that is, one that can be ...
evennia/scripts/tickerhandler.py
add
orkim/evennia
python
def add(self, interval=60, callback=None, idstring=, persistent=True, *args, **kwargs): '\n Add subscription to tickerhandler\n\n Args:\n interval (int, optional): Interval in seconds between calling\n `callable(*args, **kwargs)`\n callable (callable function or me...
def remove(self, interval=60, callback=None, idstring='', persistent=True): '\n Remove object from ticker or only remove it from tickers with\n a given interval.\n\n Args:\n interval (int, optional): Interval of ticker to remove.\n callback (callable function or method): E...
7,312,347,190,382,608,000
Remove object from ticker or only remove it from tickers with a given interval. Args: interval (int, optional): Interval of ticker to remove. callback (callable function or method): Either a function or the method of a typeclassed object. idstring (str, optional): Identifier id of ticker to remove.
evennia/scripts/tickerhandler.py
remove
orkim/evennia
python
def remove(self, interval=60, callback=None, idstring=, persistent=True): '\n Remove object from ticker or only remove it from tickers with\n a given interval.\n\n Args:\n interval (int, optional): Interval of ticker to remove.\n callback (callable function or method): Eit...
def clear(self, interval=None): '\n Stop/remove tickers from handler.\n\n Args:\n interval (int): Only stop tickers with this interval.\n\n Notes:\n This is the only supported way to kill tickers related to\n non-db objects.\n\n ' self.ticker_pool.sto...
952,231,011,741,671,700
Stop/remove tickers from handler. Args: interval (int): Only stop tickers with this interval. Notes: This is the only supported way to kill tickers related to non-db objects.
evennia/scripts/tickerhandler.py
clear
orkim/evennia
python
def clear(self, interval=None): '\n Stop/remove tickers from handler.\n\n Args:\n interval (int): Only stop tickers with this interval.\n\n Notes:\n This is the only supported way to kill tickers related to\n non-db objects.\n\n ' self.ticker_pool.sto...
def all(self, interval=None): '\n Get all subscriptions.\n\n Args:\n interval (int): Limit match to tickers with this interval.\n\n Returns:\n tickers (list): If `interval` was given, this is a list of\n tickers using that interval.\n tickerpool_l...
4,919,551,878,231,397,000
Get all subscriptions. Args: interval (int): Limit match to tickers with this interval. Returns: tickers (list): If `interval` was given, this is a list of tickers using that interval. tickerpool_layout (dict): If `interval` was *not* given, this is a dict {interval1: [ticker1, ticker2, .....
evennia/scripts/tickerhandler.py
all
orkim/evennia
python
def all(self, interval=None): '\n Get all subscriptions.\n\n Args:\n interval (int): Limit match to tickers with this interval.\n\n Returns:\n tickers (list): If `interval` was given, this is a list of\n tickers using that interval.\n tickerpool_l...
def all_display(self): '\n Get all tickers on an easily displayable form.\n\n Returns:\n tickers (dict): A list of all storekeys\n\n ' store_keys = [] for ticker in self.ticker_pool.tickers.itervalues(): for ((objtup, callfunc, path, interval, idstring, persistent), (...
-7,547,110,222,363,837,000
Get all tickers on an easily displayable form. Returns: tickers (dict): A list of all storekeys
evennia/scripts/tickerhandler.py
all_display
orkim/evennia
python
def all_display(self): '\n Get all tickers on an easily displayable form.\n\n Returns:\n tickers (dict): A list of all storekeys\n\n ' store_keys = [] for ticker in self.ticker_pool.tickers.itervalues(): for ((objtup, callfunc, path, interval, idstring, persistent), (...
def parse_command_line(): 'Parse the command line options' desc = 'The Stars Align - Day 10 of Advent of Code 2018' sample = 'sample: python aoc_10.py input.txt' parser = argparse.ArgumentParser(description=desc, epilog=sample) parser.add_argument('-v', '--verbose', action='store_true', default=Fals...
-1,921,321,716,781,806,600
Parse the command line options
2018/10_TheStarsAlign/aoc_10.py
parse_command_line
deanearlwright/AdventOfCode
python
def parse_command_line(): desc = 'The Stars Align - Day 10 of Advent of Code 2018' sample = 'sample: python aoc_10.py input.txt' parser = argparse.ArgumentParser(description=desc, epilog=sample) parser.add_argument('-v', '--verbose', action='store_true', default=False, dest='verbose', help='Print s...
def part_one(args, input_lines): 'Process part one of the puzzle' solver = lights.Lights(part2=False, text=input_lines) solution = solver.part_one(verbose=args.verbose, limit=args.limit) if (solution is None): print('There is no solution') else: print(('The solution for part one is %...
3,090,454,062,781,860,000
Process part one of the puzzle
2018/10_TheStarsAlign/aoc_10.py
part_one
deanearlwright/AdventOfCode
python
def part_one(args, input_lines): solver = lights.Lights(part2=False, text=input_lines) solution = solver.part_one(verbose=args.verbose, limit=args.limit) if (solution is None): print('There is no solution') else: print(('The solution for part one is %s' % solution)) return (solu...
def part_two(args, input_lines): 'Process part two of the puzzle' solver = lights.Lights(part2=True, text=input_lines) solution = solver.part_two(verbose=args.verbose, limit=args.limit) if (solution is None): print('There is no solution') else: print(('The solution for part two is %s...
-7,008,301,873,587,400,000
Process part two of the puzzle
2018/10_TheStarsAlign/aoc_10.py
part_two
deanearlwright/AdventOfCode
python
def part_two(args, input_lines): solver = lights.Lights(part2=True, text=input_lines) solution = solver.part_two(verbose=args.verbose, limit=args.limit) if (solution is None): print('There is no solution') else: print(('The solution for part two is %s' % solution)) return (solut...
def from_file(filepath): 'Read the file' return from_text(open(filepath).read())
5,800,071,608,339,332,000
Read the file
2018/10_TheStarsAlign/aoc_10.py
from_file
deanearlwright/AdventOfCode
python
def from_file(filepath): return from_text(open(filepath).read())
def from_text(text): 'Break the text into trimed, non-comment lines' lines = [] for line in text.split('\n'): line = line.rstrip(' \r') if (not line): continue if line.startswith('!'): continue lines.append(line) return lines
-6,028,014,871,540,136,000
Break the text into trimed, non-comment lines
2018/10_TheStarsAlign/aoc_10.py
from_text
deanearlwright/AdventOfCode
python
def from_text(text): lines = [] for line in text.split('\n'): line = line.rstrip(' \r') if (not line): continue if line.startswith('!'): continue lines.append(line) return lines
def main(): 'Read the Advent of Code problem and solve it' args = parse_command_line() input_text = from_file(args.filepath) if (args.part == 1): result = part_one(args, input_text) else: result = part_two(args, input_text) if result: sys.exit(0) sys.exit(2)
3,592,193,595,729,941,500
Read the Advent of Code problem and solve it
2018/10_TheStarsAlign/aoc_10.py
main
deanearlwright/AdventOfCode
python
def main(): args = parse_command_line() input_text = from_file(args.filepath) if (args.part == 1): result = part_one(args, input_text) else: result = part_two(args, input_text) if result: sys.exit(0) sys.exit(2)
def read_country_code(): '\n 获取国家中英文字典\n :return:\n ' country_dict = {} for (key, val) in namemap.nameMap.items(): country_dict[val] = key return country_dict
-7,936,220,243,036,575,000
获取国家中英文字典 :return:
python-data-analysis/2019-nCoV-global/global_map.py
read_country_code
DearCasper/python-learning
python
def read_country_code(): '\n 获取国家中英文字典\n :return:\n ' country_dict = {} for (key, val) in namemap.nameMap.items(): country_dict[val] = key return country_dict
def read_csv(): '\n 读取数据,返回国家英文名称列表和累计确诊数列表\n :return:\n ' country_dict = read_country_code() data = pd.read_csv('2019-nCoV.csv', index_col=False) countrys_names = list() confirmed_count = list() for x in range(len(data.index)): if (data['name'].iloc[x] in country_dict.keys()): ...
-7,097,631,232,518,895,000
读取数据,返回国家英文名称列表和累计确诊数列表 :return:
python-data-analysis/2019-nCoV-global/global_map.py
read_csv
DearCasper/python-learning
python
def read_csv(): '\n 读取数据,返回国家英文名称列表和累计确诊数列表\n :return:\n ' country_dict = read_country_code() data = pd.read_csv('2019-nCoV.csv', index_col=False) countrys_names = list() confirmed_count = list() for x in range(len(data.index)): if (data['name'].iloc[x] in country_dict.keys()): ...