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
RachioSchedule.unique_id
(self)
Return a unique id by combining controller id and schedule.
Return a unique id by combining controller id and schedule.
def unique_id(self) -> str: """Return a unique id by combining controller id and schedule.""" return f"{self._controller.controller_id}-schedule-{self._schedule_id}"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "f\"{self._controller.controller_id}-schedule-{self._schedule_id}\"" ]
[ 488, 4 ]
[ 490, 79 ]
python
en
['en', 'en', 'en']
True
RachioSchedule.icon
(self)
Return the icon to display.
Return the icon to display.
def icon(self) -> str: """Return the icon to display.""" return "mdi:water" if self.schedule_is_enabled else "mdi:water-off"
[ "def", "icon", "(", "self", ")", "->", "str", ":", "return", "\"mdi:water\"", "if", "self", ".", "schedule_is_enabled", "else", "\"mdi:water-off\"" ]
[ 493, 4 ]
[ 495, 75 ]
python
en
['en', 'en', 'en']
True
RachioSchedule.extra_state_attributes
(self)
Return the optional state attributes.
Return the optional state attributes.
def extra_state_attributes(self) -> dict: """Return the optional state attributes.""" return { ATTR_SCHEDULE_SUMMARY: self._summary, ATTR_SCHEDULE_ENABLED: self.schedule_is_enabled, ATTR_SCHEDULE_DURATION: f"{round(self._duration / 60)} minutes", ATTR_SCHE...
[ "def", "extra_state_attributes", "(", "self", ")", "->", "dict", ":", "return", "{", "ATTR_SCHEDULE_SUMMARY", ":", "self", ".", "_summary", ",", "ATTR_SCHEDULE_ENABLED", ":", "self", ".", "schedule_is_enabled", ",", "ATTR_SCHEDULE_DURATION", ":", "f\"{round(self._dura...
[ 498, 4 ]
[ 505, 9 ]
python
en
['en', 'en', 'en']
True
RachioSchedule.schedule_is_enabled
(self)
Return whether the schedule is allowed to run.
Return whether the schedule is allowed to run.
def schedule_is_enabled(self) -> bool: """Return whether the schedule is allowed to run.""" return self._schedule_enabled
[ "def", "schedule_is_enabled", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_schedule_enabled" ]
[ 508, 4 ]
[ 510, 37 ]
python
en
['en', 'en', 'en']
True
RachioSchedule.turn_on
(self, **kwargs)
Start this schedule.
Start this schedule.
def turn_on(self, **kwargs) -> None: """Start this schedule.""" self._controller.rachio.schedulerule.start(self._schedule_id) _LOGGER.debug( "Schedule %s started on %s", self.name, self._controller.name, )
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "self", ".", "_controller", ".", "rachio", ".", "schedulerule", ".", "start", "(", "self", ".", "_schedule_id", ")", "_LOGGER", ".", "debug", "(", "\"Schedule %s started on %s\...
[ 512, 4 ]
[ 519, 9 ]
python
en
['en', 'de', 'en']
True
RachioSchedule.turn_off
(self, **kwargs)
Stop watering all zones.
Stop watering all zones.
def turn_off(self, **kwargs) -> None: """Stop watering all zones.""" self._controller.stop_watering()
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "self", ".", "_controller", ".", "stop_watering", "(", ")" ]
[ 521, 4 ]
[ 523, 40 ]
python
en
['en', 'nl', 'en']
True
RachioSchedule._async_handle_update
(self, *args, **kwargs)
Handle incoming webhook schedule data.
Handle incoming webhook schedule data.
def _async_handle_update(self, *args, **kwargs) -> None: """Handle incoming webhook schedule data.""" # Schedule ID not passed when running individual zones, so we catch that error with suppress(KeyError): if args[0][KEY_SCHEDULE_ID] == self._schedule_id: if args[0][K...
[ "def", "_async_handle_update", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "->", "None", ":", "# Schedule ID not passed when running individual zones, so we catch that error", "with", "suppress", "(", "KeyError", ")", ":", "if", "args", "[", "0", ...
[ 526, 4 ]
[ 539, 35 ]
python
de
['de', 'nl', 'en']
False
RachioSchedule.async_added_to_hass
(self)
Subscribe to updates.
Subscribe to updates.
async def async_added_to_hass(self): """Subscribe to updates.""" self._state = self._schedule_id == self._current_schedule.get(KEY_SCHEDULE_ID) self.async_on_remove( async_dispatcher_connect( self.hass, SIGNAL_RACHIO_SCHEDULE_UPDATE, self._async_handle_update ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "_state", "=", "self", ".", "_schedule_id", "==", "self", ".", "_current_schedule", ".", "get", "(", "KEY_SCHEDULE_ID", ")", "self", ".", "async_on_remove", "(", "async_dispatcher_connect...
[ 541, 4 ]
[ 549, 9 ]
python
en
['en', 'en', 'en']
True
GTestXMLOutputUnitTest.testEmptyXmlOutput
(self)
Verifies XML output for a Google Test binary without actual tests. Runs a test program that generates an empty XML output, and tests that the XML output is expected.
Verifies XML output for a Google Test binary without actual tests.
def testEmptyXmlOutput(self): """Verifies XML output for a Google Test binary without actual tests. Runs a test program that generates an empty XML output, and tests that the XML output is expected. """ self._TestXmlOutput('gtest_no_test_unittest', EXPECTED_EMPTY_XML, 0)
[ "def", "testEmptyXmlOutput", "(", "self", ")", ":", "self", ".", "_TestXmlOutput", "(", "'gtest_no_test_unittest'", ",", "EXPECTED_EMPTY_XML", ",", "0", ")" ]
[ 244, 2 ]
[ 251, 72 ]
python
en
['en', 'en', 'en']
True
GTestXMLOutputUnitTest.testTimestampValue
(self)
Checks whether the timestamp attribute in the XML output is valid. Runs a test program that generates an empty XML output, and checks if the timestamp attribute in the testsuites tag is valid.
Checks whether the timestamp attribute in the XML output is valid.
def testTimestampValue(self): """Checks whether the timestamp attribute in the XML output is valid. Runs a test program that generates an empty XML output, and checks if the timestamp attribute in the testsuites tag is valid. """ actual = self._GetXmlOutput('gtest_no_test_unittest', [], {}, 0) ...
[ "def", "testTimestampValue", "(", "self", ")", ":", "actual", "=", "self", ".", "_GetXmlOutput", "(", "'gtest_no_test_unittest'", ",", "[", "]", ",", "{", "}", ",", "0", ")", "date_time_str", "=", "actual", ".", "documentElement", ".", "getAttributeNode", "(...
[ 253, 2 ]
[ 276, 19 ]
python
en
['en', 'en', 'en']
True
GTestXMLOutputUnitTest.testDefaultOutputFile
(self)
Confirms that Google Test produces an XML output file with the expected default name if no name is explicitly specified.
Confirms that Google Test produces an XML output file with the expected default name if no name is explicitly specified.
def testDefaultOutputFile(self): """ Confirms that Google Test produces an XML output file with the expected default name if no name is explicitly specified. """ output_file = os.path.join(gtest_test_utils.GetTempDir(), GTEST_DEFAULT_OUTPUT_FILE) gtest_prog_path = ...
[ "def", "testDefaultOutputFile", "(", "self", ")", ":", "output_file", "=", "os", ".", "path", ".", "join", "(", "gtest_test_utils", ".", "GetTempDir", "(", ")", ",", "GTEST_DEFAULT_OUTPUT_FILE", ")", "gtest_prog_path", "=", "gtest_test_utils", ".", "GetTestExecuta...
[ 278, 2 ]
[ 299, 45 ]
python
en
['en', 'error', 'th']
False
GTestXMLOutputUnitTest.testSuppressedXmlOutput
(self)
Tests that no XML file is generated if the default XML listener is shut down before RUN_ALL_TESTS is invoked.
Tests that no XML file is generated if the default XML listener is shut down before RUN_ALL_TESTS is invoked.
def testSuppressedXmlOutput(self): """ Tests that no XML file is generated if the default XML listener is shut down before RUN_ALL_TESTS is invoked. """ xml_path = os.path.join(gtest_test_utils.GetTempDir(), GTEST_PROGRAM_NAME + 'out.xml') if os.path.isfile(xml_path)...
[ "def", "testSuppressedXmlOutput", "(", "self", ")", ":", "xml_path", "=", "os", ".", "path", ".", "join", "(", "gtest_test_utils", ".", "GetTempDir", "(", ")", ",", "GTEST_PROGRAM_NAME", "+", "'out.xml'", ")", "if", "os", ".", "path", ".", "isfile", "(", ...
[ 301, 2 ]
[ 328, 46 ]
python
en
['en', 'error', 'th']
False
GTestXMLOutputUnitTest.testFilteredTestXmlOutput
(self)
Verifies XML output when a filter is applied. Runs a test program that executes only some tests and verifies that non-selected tests do not show up in the XML output.
Verifies XML output when a filter is applied.
def testFilteredTestXmlOutput(self): """Verifies XML output when a filter is applied. Runs a test program that executes only some tests and verifies that non-selected tests do not show up in the XML output. """ self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_FILTERED_TEST_XML, 0, ...
[ "def", "testFilteredTestXmlOutput", "(", "self", ")", ":", "self", ".", "_TestXmlOutput", "(", "GTEST_PROGRAM_NAME", ",", "EXPECTED_FILTERED_TEST_XML", ",", "0", ",", "extra_args", "=", "[", "'%s=SuccessfulTest.*'", "%", "GTEST_FILTER_FLAG", "]", ")" ]
[ 330, 2 ]
[ 338, 79 ]
python
en
['en', 'en', 'en']
True
GTestXMLOutputUnitTest.testShardedTestXmlOutput
(self)
Verifies XML output when run using multiple shards. Runs a test program that executes only one shard and verifies that tests from other shards do not show up in the XML output.
Verifies XML output when run using multiple shards.
def testShardedTestXmlOutput(self): """Verifies XML output when run using multiple shards. Runs a test program that executes only one shard and verifies that tests from other shards do not show up in the XML output. """ self._TestXmlOutput( GTEST_PROGRAM_NAME, EXPECTED_SHARDED_TEST...
[ "def", "testShardedTestXmlOutput", "(", "self", ")", ":", "self", ".", "_TestXmlOutput", "(", "GTEST_PROGRAM_NAME", ",", "EXPECTED_SHARDED_TEST_XML", ",", "0", ",", "extra_env", "=", "{", "SHARD_INDEX_ENV_VAR", ":", "'0'", ",", "TOTAL_SHARDS_ENV_VAR", ":", "'10'", ...
[ 340, 2 ]
[ 352, 47 ]
python
en
['en', 'lb', 'en']
True
GTestXMLOutputUnitTest._GetXmlOutput
(self, gtest_prog_name, extra_args, extra_env, expected_exit_code)
Returns the xml output generated by running the program gtest_prog_name. Furthermore, the program's exit code must be expected_exit_code.
Returns the xml output generated by running the program gtest_prog_name. Furthermore, the program's exit code must be expected_exit_code.
def _GetXmlOutput(self, gtest_prog_name, extra_args, extra_env, expected_exit_code): """ Returns the xml output generated by running the program gtest_prog_name. Furthermore, the program's exit code must be expected_exit_code. """ xml_path = os.path.join(gtest_test_utils.GetTempD...
[ "def", "_GetXmlOutput", "(", "self", ",", "gtest_prog_name", ",", "extra_args", ",", "extra_env", ",", "expected_exit_code", ")", ":", "xml_path", "=", "os", ".", "path", ".", "join", "(", "gtest_test_utils", ".", "GetTempDir", "(", ")", ",", "gtest_prog_name"...
[ 354, 2 ]
[ 381, 17 ]
python
en
['en', 'error', 'th']
False
GTestXMLOutputUnitTest._TestXmlOutput
(self, gtest_prog_name, expected_xml, expected_exit_code, extra_args=None, extra_env=None)
Asserts that the XML document generated by running the program gtest_prog_name matches expected_xml, a string containing another XML document. Furthermore, the program's exit code must be expected_exit_code.
Asserts that the XML document generated by running the program gtest_prog_name matches expected_xml, a string containing another XML document. Furthermore, the program's exit code must be expected_exit_code.
def _TestXmlOutput(self, gtest_prog_name, expected_xml, expected_exit_code, extra_args=None, extra_env=None): """ Asserts that the XML document generated by running the program gtest_prog_name matches expected_xml, a string containing another XML document. Furthermore, the program'...
[ "def", "_TestXmlOutput", "(", "self", ",", "gtest_prog_name", ",", "expected_xml", ",", "expected_exit_code", ",", "extra_args", "=", "None", ",", "extra_env", "=", "None", ")", ":", "actual", "=", "self", ".", "_GetXmlOutput", "(", "gtest_prog_name", ",", "ex...
[ 383, 2 ]
[ 399, 19 ]
python
en
['en', 'error', 'th']
False
setup
(hass, base_config)
Set up the Lutron integration.
Set up the Lutron integration.
def setup(hass, base_config): """Set up the Lutron integration.""" hass.data[LUTRON_BUTTONS] = [] hass.data[LUTRON_CONTROLLER] = None hass.data[LUTRON_DEVICES] = { "light": [], "cover": [], "switch": [], "scene": [], "binary_sensor": [], } config = base_c...
[ "def", "setup", "(", "hass", ",", "base_config", ")", ":", "hass", ".", "data", "[", "LUTRON_BUTTONS", "]", "=", "[", "]", "hass", ".", "data", "[", "LUTRON_CONTROLLER", "]", "=", "None", "hass", ".", "data", "[", "LUTRON_DEVICES", "]", "=", "{", "\"...
[ 40, 0 ]
[ 98, 15 ]
python
en
['en', 'fr', 'en']
True
LutronDevice.__init__
(self, area_name, lutron_device, controller)
Initialize the device.
Initialize the device.
def __init__(self, area_name, lutron_device, controller): """Initialize the device.""" self._lutron_device = lutron_device self._controller = controller self._area_name = area_name
[ "def", "__init__", "(", "self", ",", "area_name", ",", "lutron_device", ",", "controller", ")", ":", "self", ".", "_lutron_device", "=", "lutron_device", "self", ".", "_controller", "=", "controller", "self", ".", "_area_name", "=", "area_name" ]
[ 104, 4 ]
[ 108, 35 ]
python
en
['en', 'en', 'en']
True
LutronDevice.async_added_to_hass
(self)
Register callbacks.
Register callbacks.
async def async_added_to_hass(self): """Register callbacks.""" self.hass.async_add_executor_job( self._lutron_device.subscribe, self._update_callback, None )
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "_lutron_device", ".", "subscribe", ",", "self", ".", "_update_callback", ",", "None", ")" ]
[ 110, 4 ]
[ 114, 9 ]
python
en
['en', 'no', 'en']
False
LutronDevice._update_callback
(self, _device, _context, _event, _params)
Run when invoked by pylutron when the device state changes.
Run when invoked by pylutron when the device state changes.
def _update_callback(self, _device, _context, _event, _params): """Run when invoked by pylutron when the device state changes.""" self.schedule_update_ha_state()
[ "def", "_update_callback", "(", "self", ",", "_device", ",", "_context", ",", "_event", ",", "_params", ")", ":", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 116, 4 ]
[ 118, 39 ]
python
en
['en', 'en', 'en']
True
LutronDevice.name
(self)
Return the name of the device.
Return the name of the device.
def name(self): """Return the name of the device.""" return f"{self._area_name} {self._lutron_device.name}"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self._area_name} {self._lutron_device.name}\"" ]
[ 121, 4 ]
[ 123, 62 ]
python
en
['en', 'en', 'en']
True
LutronDevice.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 126, 4 ]
[ 128, 20 ]
python
en
['en', 'en', 'en']
True
LutronDevice.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" return f"{self._controller.guid}_{self._lutron_device.uuid}"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"{self._controller.guid}_{self._lutron_device.uuid}\"" ]
[ 131, 4 ]
[ 133, 68 ]
python
ca
['fr', 'ca', 'en']
False
LutronButton.__init__
(self, hass, area_name, keypad, button)
Register callback for activity on the button.
Register callback for activity on the button.
def __init__(self, hass, area_name, keypad, button): """Register callback for activity on the button.""" name = f"{keypad.name}: {button.name}" if button.name == "Unknown Button": name += f" {button.number}" self._hass = hass self._has_release_event = ( bu...
[ "def", "__init__", "(", "self", ",", "hass", ",", "area_name", ",", "keypad", ",", "button", ")", ":", "name", "=", "f\"{keypad.name}: {button.name}\"", "if", "button", ".", "name", "==", "\"Unknown Button\"", ":", "name", "+=", "f\" {button.number}\"", "self", ...
[ 144, 4 ]
[ 161, 52 ]
python
en
['en', 'en', 'en']
True
LutronButton.button_callback
(self, button, context, event, params)
Fire an event about a button being pressed or released.
Fire an event about a button being pressed or released.
def button_callback(self, button, context, event, params): """Fire an event about a button being pressed or released.""" # Events per button type: # RaiseLower -> pressed/released # SingleAction -> single action = None if self._has_release_event: if event ...
[ "def", "button_callback", "(", "self", ",", "button", ",", "context", ",", "event", ",", "params", ")", ":", "# Events per button type:", "# RaiseLower -> pressed/released", "# SingleAction -> single", "action", "=", "None", "if", "self", ".", "_has_release_event", ...
[ 163, 4 ]
[ 179, 50 ]
python
en
['en', 'en', 'en']
True
delay_fixture
()
Patch the delay script function.
Patch the delay script function.
def delay_fixture(): """Patch the delay script function.""" with patch( "homeassistant.components.samsungtv.media_player.Script.async_run" ) as delay: yield delay
[ "def", "delay_fixture", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.samsungtv.media_player.Script.async_run\"", ")", "as", "delay", ":", "yield", "delay" ]
[ 121, 0 ]
[ 126, 19 ]
python
en
['en', 'en', 'en']
True
mock_now
()
Fixture for dtutil.now.
Fixture for dtutil.now.
def mock_now(): """Fixture for dtutil.now.""" return dt_util.utcnow()
[ "def", "mock_now", "(", ")", ":", "return", "dt_util", ".", "utcnow", "(", ")" ]
[ 130, 0 ]
[ 132, 27 ]
python
da
['da', 'da', 'en']
True
setup_samsungtv
(hass, config)
Set up mock Samsung TV.
Set up mock Samsung TV.
async def setup_samsungtv(hass, config): """Set up mock Samsung TV.""" await async_setup_component(hass, SAMSUNGTV_DOMAIN, config) await hass.async_block_till_done()
[ "async", "def", "setup_samsungtv", "(", "hass", ",", "config", ")", ":", "await", "async_setup_component", "(", "hass", ",", "SAMSUNGTV_DOMAIN", ",", "config", ")", "await", "hass", ".", "async_block_till_done", "(", ")" ]
[ 135, 0 ]
[ 138, 38 ]
python
en
['en', 'da', 'en']
True
test_setup_with_turnon
(hass, remote)
Test setup of platform.
Test setup of platform.
async def test_setup_with_turnon(hass, remote): """Test setup of platform.""" await setup_samsungtv(hass, MOCK_CONFIG) assert hass.states.get(ENTITY_ID)
[ "async", "def", "test_setup_with_turnon", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "assert", "hass", ".", "states", ".", "get", "(", "ENTITY_ID", ")" ]
[ 141, 0 ]
[ 144, 37 ]
python
en
['en', 'da', 'en']
True
test_setup_without_turnon
(hass, remote)
Test setup of platform.
Test setup of platform.
async def test_setup_without_turnon(hass, remote): """Test setup of platform.""" await setup_samsungtv(hass, MOCK_CONFIG_NOTURNON) assert hass.states.get(ENTITY_ID_NOTURNON)
[ "async", "def", "test_setup_without_turnon", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG_NOTURNON", ")", "assert", "hass", ".", "states", ".", "get", "(", "ENTITY_ID_NOTURNON", ")" ]
[ 147, 0 ]
[ 150, 46 ]
python
en
['en', 'da', 'en']
True
test_setup_websocket
(hass, remotews, mock_now)
Test setup of platform.
Test setup of platform.
async def test_setup_websocket(hass, remotews, mock_now): """Test setup of platform.""" with patch("homeassistant.components.samsungtv.bridge.SamsungTVWS") as remote_class: enter = Mock() type(enter).token = PropertyMock(return_value="987654321") remote = Mock() remote.__enter__ ...
[ "async", "def", "test_setup_websocket", "(", "hass", ",", "remotews", ",", "mock_now", ")", ":", "with", "patch", "(", "\"homeassistant.components.samsungtv.bridge.SamsungTVWS\"", ")", "as", "remote_class", ":", "enter", "=", "Mock", "(", ")", "type", "(", "enter"...
[ 153, 0 ]
[ 186, 70 ]
python
en
['en', 'da', 'en']
True
test_setup_websocket_2
(hass, mock_now)
Test setup of platform from config entry.
Test setup of platform from config entry.
async def test_setup_websocket_2(hass, mock_now): """Test setup of platform from config entry.""" entity_id = f"{DOMAIN}.fake" entry = MockConfigEntry( domain=SAMSUNGTV_DOMAIN, data=MOCK_ENTRY_WS, unique_id=entity_id, ) entry.add_to_hass(hass) config_entries = hass.conf...
[ "async", "def", "test_setup_websocket_2", "(", "hass", ",", "mock_now", ")", ":", "entity_id", "=", "f\"{DOMAIN}.fake\"", "entry", "=", "MockConfigEntry", "(", "domain", "=", "SAMSUNGTV_DOMAIN", ",", "data", "=", "MOCK_ENTRY_WS", ",", "unique_id", "=", "entity_id"...
[ 189, 0 ]
[ 234, 66 ]
python
en
['en', 'da', 'en']
True
test_update_on
(hass, remote, mock_now)
Testing update tv on.
Testing update tv on.
async def test_update_on(hass, remote, mock_now): """Testing update tv on.""" await setup_samsungtv(hass, MOCK_CONFIG) next_update = mock_now + timedelta(minutes=5) with patch("homeassistant.util.dt.utcnow", return_value=next_update): async_fire_time_changed(hass, next_update) await has...
[ "async", "def", "test_update_on", "(", "hass", ",", "remote", ",", "mock_now", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "next_update", "=", "mock_now", "+", "timedelta", "(", "minutes", "=", "5", ")", "with", "patch", "("...
[ 237, 0 ]
[ 247, 34 ]
python
en
['sv', 'en', 'en']
True
test_update_off
(hass, remote, mock_now)
Testing update tv off.
Testing update tv off.
async def test_update_off(hass, remote, mock_now): """Testing update tv off.""" await setup_samsungtv(hass, MOCK_CONFIG) with patch( "homeassistant.components.samsungtv.bridge.Remote", side_effect=[OSError("Boom"), DEFAULT_MOCK], ): next_update = mock_now + timedelta(minutes=5)...
[ "async", "def", "test_update_off", "(", "hass", ",", "remote", ",", "mock_now", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "with", "patch", "(", "\"homeassistant.components.samsungtv.bridge.Remote\"", ",", "side_effect", "=", "[", ...
[ 250, 0 ]
[ 265, 39 ]
python
en
['en', 'co', 'en']
True
test_update_access_denied
(hass, remote, mock_now)
Testing update tv access denied exception.
Testing update tv access denied exception.
async def test_update_access_denied(hass, remote, mock_now): """Testing update tv access denied exception.""" await setup_samsungtv(hass, MOCK_CONFIG) with patch( "homeassistant.components.samsungtv.bridge.Remote", side_effect=exceptions.AccessDenied("Boom"), ): next_update = mo...
[ "async", "def", "test_update_access_denied", "(", "hass", ",", "remote", ",", "mock_now", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "with", "patch", "(", "\"homeassistant.components.samsungtv.bridge.Remote\"", ",", "side_effect", "=",...
[ 268, 0 ]
[ 291, 43 ]
python
en
['da', 'en', 'en']
True
test_update_connection_failure
(hass, remotews, mock_now)
Testing update tv connection failure exception.
Testing update tv connection failure exception.
async def test_update_connection_failure(hass, remotews, mock_now): """Testing update tv connection failure exception.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", side_effect=[OSError("Boom"), DEFAULT_MOCK], ): await setup_samsungtv(hass, MOCK_CONFIGWS) ...
[ "async", "def", "test_update_connection_failure", "(", "hass", ",", "remotews", ",", "mock_now", ")", ":", "with", "patch", "(", "\"homeassistant.components.samsungtv.bridge.Remote\"", ",", "side_effect", "=", "[", "OSError", "(", "\"Boom\"", ")", ",", "DEFAULT_MOCK",...
[ 294, 0 ]
[ 321, 43 ]
python
en
['fr', 'en', 'en']
True
test_update_unhandled_response
(hass, remote, mock_now)
Testing update tv unhandled response exception.
Testing update tv unhandled response exception.
async def test_update_unhandled_response(hass, remote, mock_now): """Testing update tv unhandled response exception.""" await setup_samsungtv(hass, MOCK_CONFIG) with patch( "homeassistant.components.samsungtv.bridge.Remote", side_effect=[exceptions.UnhandledResponse("Boom"), DEFAULT_MOCK], ...
[ "async", "def", "test_update_unhandled_response", "(", "hass", ",", "remote", ",", "mock_now", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "with", "patch", "(", "\"homeassistant.components.samsungtv.bridge.Remote\"", ",", "side_effect", ...
[ 324, 0 ]
[ 339, 38 ]
python
en
['en', 'en', 'en']
True
test_connection_closed_during_update_can_recover
(hass, remote, mock_now)
Testing update tv connection closed exception can recover.
Testing update tv connection closed exception can recover.
async def test_connection_closed_during_update_can_recover(hass, remote, mock_now): """Testing update tv connection closed exception can recover.""" await setup_samsungtv(hass, MOCK_CONFIG) with patch( "homeassistant.components.samsungtv.bridge.Remote", side_effect=[exceptions.ConnectionClo...
[ "async", "def", "test_connection_closed_during_update_can_recover", "(", "hass", ",", "remote", ",", "mock_now", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "with", "patch", "(", "\"homeassistant.components.samsungtv.bridge.Remote\"", ",", ...
[ 342, 0 ]
[ 365, 38 ]
python
en
['en', 'en', 'en']
True
test_send_key
(hass, remote)
Test for send key.
Test for send key.
async def test_send_key(hass, remote): """Test for send key.""" await setup_samsungtv(hass, MOCK_CONFIG) assert await hass.services.async_call( DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True ) state = hass.states.get(ENTITY_ID) # key and update called assert remote.cont...
[ "async", "def", "test_send_key", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "assert", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_VOLUME_UP", ",", "{", "ATTR_E...
[ 368, 0 ]
[ 380, 34 ]
python
en
['en', 'cy', 'en']
True
test_send_key_broken_pipe
(hass, remote)
Testing broken pipe Exception.
Testing broken pipe Exception.
async def test_send_key_broken_pipe(hass, remote): """Testing broken pipe Exception.""" await setup_samsungtv(hass, MOCK_CONFIG) remote.control = Mock(side_effect=BrokenPipeError("Boom")) assert await hass.services.async_call( DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True ) ...
[ "async", "def", "test_send_key_broken_pipe", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "remote", ".", "control", "=", "Mock", "(", "side_effect", "=", "BrokenPipeError", "(", "\"Boom\"", ")", ")", ...
[ 383, 0 ]
[ 391, 34 ]
python
en
['nl', 'en', 'en']
True
test_send_key_connection_closed_retry_succeed
(hass, remote)
Test retry on connection closed.
Test retry on connection closed.
async def test_send_key_connection_closed_retry_succeed(hass, remote): """Test retry on connection closed.""" await setup_samsungtv(hass, MOCK_CONFIG) remote.control = Mock( side_effect=[exceptions.ConnectionClosed("Boom"), DEFAULT_MOCK, DEFAULT_MOCK] ) assert await hass.services.async_call(...
[ "async", "def", "test_send_key_connection_closed_retry_succeed", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "remote", ".", "control", "=", "Mock", "(", "side_effect", "=", "[", "exceptions", ".", "Conn...
[ 394, 0 ]
[ 412, 34 ]
python
en
['en', 'en', 'en']
True
test_send_key_unhandled_response
(hass, remote)
Testing unhandled response exception.
Testing unhandled response exception.
async def test_send_key_unhandled_response(hass, remote): """Testing unhandled response exception.""" await setup_samsungtv(hass, MOCK_CONFIG) remote.control = Mock(side_effect=exceptions.UnhandledResponse("Boom")) assert await hass.services.async_call( DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID...
[ "async", "def", "test_send_key_unhandled_response", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "remote", ".", "control", "=", "Mock", "(", "side_effect", "=", "exceptions", ".", "UnhandledResponse", "(...
[ 415, 0 ]
[ 423, 34 ]
python
en
['en', 'en', 'en']
True
test_send_key_websocketexception
(hass, remote)
Testing unhandled response exception.
Testing unhandled response exception.
async def test_send_key_websocketexception(hass, remote): """Testing unhandled response exception.""" await setup_samsungtv(hass, MOCK_CONFIG) remote.control = Mock(side_effect=WebSocketException("Boom")) assert await hass.services.async_call( DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_I...
[ "async", "def", "test_send_key_websocketexception", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "remote", ".", "control", "=", "Mock", "(", "side_effect", "=", "WebSocketException", "(", "\"Boom\"", ")"...
[ 426, 0 ]
[ 434, 34 ]
python
en
['en', 'en', 'en']
True
test_send_key_os_error
(hass, remote)
Testing broken pipe Exception.
Testing broken pipe Exception.
async def test_send_key_os_error(hass, remote): """Testing broken pipe Exception.""" await setup_samsungtv(hass, MOCK_CONFIG) remote.control = Mock(side_effect=OSError("Boom")) assert await hass.services.async_call( DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True ) state = h...
[ "async", "def", "test_send_key_os_error", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "remote", ".", "control", "=", "Mock", "(", "side_effect", "=", "OSError", "(", "\"Boom\"", ")", ")", "assert", ...
[ 437, 0 ]
[ 445, 34 ]
python
en
['nl', 'en', 'en']
True
test_name
(hass, remote)
Test for name property.
Test for name property.
async def test_name(hass, remote): """Test for name property.""" await setup_samsungtv(hass, MOCK_CONFIG) state = hass.states.get(ENTITY_ID) assert state.attributes[ATTR_FRIENDLY_NAME] == "fake"
[ "async", "def", "test_name", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "ENTITY_ID", ")", "assert", "state", ".", "attributes", "[", "ATTR_...
[ 448, 0 ]
[ 452, 57 ]
python
en
['en', 'en', 'en']
True
test_state_with_turnon
(hass, remote, delay)
Test for state property.
Test for state property.
async def test_state_with_turnon(hass, remote, delay): """Test for state property.""" await setup_samsungtv(hass, MOCK_CONFIG) assert await hass.services.async_call( DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_ID}, True ) state = hass.states.get(ENTITY_ID) assert state.state == STAT...
[ "async", "def", "test_state_with_turnon", "(", "hass", ",", "remote", ",", "delay", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "assert", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_TURN_ON"...
[ 455, 0 ]
[ 469, 35 ]
python
en
['en', 'en', 'en']
True
test_state_without_turnon
(hass, remote)
Test for state property.
Test for state property.
async def test_state_without_turnon(hass, remote): """Test for state property.""" await setup_samsungtv(hass, MOCK_CONFIG_NOTURNON) assert await hass.services.async_call( DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID_NOTURNON}, True ) state = hass.states.get(ENTITY_ID_NOTURNON) a...
[ "async", "def", "test_state_without_turnon", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG_NOTURNON", ")", "assert", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_VOLUME_UP", ...
[ 472, 0 ]
[ 497, 43 ]
python
en
['en', 'en', 'en']
True
test_supported_features_with_turnon
(hass, remote)
Test for supported_features property.
Test for supported_features property.
async def test_supported_features_with_turnon(hass, remote): """Test for supported_features property.""" await setup_samsungtv(hass, MOCK_CONFIG) state = hass.states.get(ENTITY_ID) assert ( state.attributes[ATTR_SUPPORTED_FEATURES] == SUPPORT_SAMSUNGTV | SUPPORT_TURN_ON )
[ "async", "def", "test_supported_features_with_turnon", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "ENTITY_ID", ")", "assert", "(", "state", "."...
[ 500, 0 ]
[ 506, 5 ]
python
en
['en', 'en', 'en']
True
test_supported_features_without_turnon
(hass, remote)
Test for supported_features property.
Test for supported_features property.
async def test_supported_features_without_turnon(hass, remote): """Test for supported_features property.""" await setup_samsungtv(hass, MOCK_CONFIG_NOTURNON) state = hass.states.get(ENTITY_ID_NOTURNON) assert state.attributes[ATTR_SUPPORTED_FEATURES] == SUPPORT_SAMSUNGTV
[ "async", "def", "test_supported_features_without_turnon", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG_NOTURNON", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "ENTITY_ID_NOTURNON", ")", "assert", ...
[ 509, 0 ]
[ 513, 73 ]
python
en
['en', 'en', 'en']
True
test_device_class
(hass, remote)
Test for device_class property.
Test for device_class property.
async def test_device_class(hass, remote): """Test for device_class property.""" await setup_samsungtv(hass, MOCK_CONFIG) state = hass.states.get(ENTITY_ID) assert state.attributes[ATTR_DEVICE_CLASS] == DEVICE_CLASS_TV
[ "async", "def", "test_device_class", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "ENTITY_ID", ")", "assert", "state", ".", "attributes", "[", ...
[ 516, 0 ]
[ 520, 65 ]
python
en
['da', 'en', 'en']
True
test_turn_off_websocket
(hass, remotews)
Test for turn_off.
Test for turn_off.
async def test_turn_off_websocket(hass, remotews): """Test for turn_off.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", side_effect=[OSError("Boom"), DEFAULT_MOCK], ): await setup_samsungtv(hass, MOCK_CONFIGWS) assert await hass.services.async_call( ...
[ "async", "def", "test_turn_off_websocket", "(", "hass", ",", "remotews", ")", ":", "with", "patch", "(", "\"homeassistant.components.samsungtv.bridge.Remote\"", ",", "side_effect", "=", "[", "OSError", "(", "\"Boom\"", ")", ",", "DEFAULT_MOCK", "]", ",", ")", ":",...
[ 523, 0 ]
[ 535, 70 ]
python
en
['en', 'en', 'en']
True
test_turn_off_legacy
(hass, remote)
Test for turn_off.
Test for turn_off.
async def test_turn_off_legacy(hass, remote): """Test for turn_off.""" await setup_samsungtv(hass, MOCK_CONFIG_NOTURNON) assert await hass.services.async_call( DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID_NOTURNON}, True ) # key called assert remote.control.call_count == 1 as...
[ "async", "def", "test_turn_off_legacy", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG_NOTURNON", ")", "assert", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_TURN_OFF", ",", ...
[ 538, 0 ]
[ 546, 66 ]
python
en
['en', 'en', 'en']
True
test_turn_off_os_error
(hass, remote, caplog)
Test for turn_off with OSError.
Test for turn_off with OSError.
async def test_turn_off_os_error(hass, remote, caplog): """Test for turn_off with OSError.""" caplog.set_level(logging.DEBUG) await setup_samsungtv(hass, MOCK_CONFIG) remote.close = Mock(side_effect=OSError("BOOM")) assert await hass.services.async_call( DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTIT...
[ "async", "def", "test_turn_off_os_error", "(", "hass", ",", "remote", ",", "caplog", ")", ":", "caplog", ".", "set_level", "(", "logging", ".", "DEBUG", ")", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "remote", ".", "close", "=", "Mo...
[ 549, 0 ]
[ 557, 58 ]
python
en
['en', 'en', 'en']
True
test_volume_up
(hass, remote)
Test for volume_up.
Test for volume_up.
async def test_volume_up(hass, remote): """Test for volume_up.""" await setup_samsungtv(hass, MOCK_CONFIG) assert await hass.services.async_call( DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True ) # key and update called assert remote.control.call_count == 1 assert remote...
[ "async", "def", "test_volume_up", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "assert", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_VOLUME_UP", ",", "{", "ATTR_...
[ 560, 0 ]
[ 570, 50 ]
python
en
['nl', 'en', 'en']
True
test_volume_down
(hass, remote)
Test for volume_down.
Test for volume_down.
async def test_volume_down(hass, remote): """Test for volume_down.""" await setup_samsungtv(hass, MOCK_CONFIG) assert await hass.services.async_call( DOMAIN, SERVICE_VOLUME_DOWN, {ATTR_ENTITY_ID: ENTITY_ID}, True ) # key and update called assert remote.control.call_count == 1 assert ...
[ "async", "def", "test_volume_down", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "assert", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_VOLUME_DOWN", ",", "{", "A...
[ 573, 0 ]
[ 583, 50 ]
python
en
['nl', 'en', 'en']
True
test_mute_volume
(hass, remote)
Test for mute_volume.
Test for mute_volume.
async def test_mute_volume(hass, remote): """Test for mute_volume.""" await setup_samsungtv(hass, MOCK_CONFIG) assert await hass.services.async_call( DOMAIN, SERVICE_VOLUME_MUTE, {ATTR_ENTITY_ID: ENTITY_ID, ATTR_MEDIA_VOLUME_MUTED: True}, True, ) # key and update call...
[ "async", "def", "test_mute_volume", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "assert", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_VOLUME_MUTE", ",", "{", "A...
[ 586, 0 ]
[ 599, 50 ]
python
en
['en', 'en', 'en']
True
test_media_play
(hass, remote)
Test for media_play.
Test for media_play.
async def test_media_play(hass, remote): """Test for media_play.""" await setup_samsungtv(hass, MOCK_CONFIG) assert await hass.services.async_call( DOMAIN, SERVICE_MEDIA_PLAY, {ATTR_ENTITY_ID: ENTITY_ID}, True ) # key and update called assert remote.control.call_count == 1 assert rem...
[ "async", "def", "test_media_play", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "assert", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_MEDIA_PLAY", ",", "{", "ATT...
[ 602, 0 ]
[ 621, 58 ]
python
en
['en', 'en', 'en']
True
test_media_pause
(hass, remote)
Test for media_pause.
Test for media_pause.
async def test_media_pause(hass, remote): """Test for media_pause.""" await setup_samsungtv(hass, MOCK_CONFIG) assert await hass.services.async_call( DOMAIN, SERVICE_MEDIA_PAUSE, {ATTR_ENTITY_ID: ENTITY_ID}, True ) # key and update called assert remote.control.call_count == 1 assert ...
[ "async", "def", "test_media_pause", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "assert", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_MEDIA_PAUSE", ",", "{", "A...
[ 624, 0 ]
[ 643, 58 ]
python
en
['en', 'en', 'en']
True
test_media_next_track
(hass, remote)
Test for media_next_track.
Test for media_next_track.
async def test_media_next_track(hass, remote): """Test for media_next_track.""" await setup_samsungtv(hass, MOCK_CONFIG) assert await hass.services.async_call( DOMAIN, SERVICE_MEDIA_NEXT_TRACK, {ATTR_ENTITY_ID: ENTITY_ID}, True ) # key and update called assert remote.control.call_count =...
[ "async", "def", "test_media_next_track", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "assert", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_MEDIA_NEXT_TRACK", ",", ...
[ 646, 0 ]
[ 656, 50 ]
python
en
['en', 'no', 'en']
True
test_media_previous_track
(hass, remote)
Test for media_previous_track.
Test for media_previous_track.
async def test_media_previous_track(hass, remote): """Test for media_previous_track.""" await setup_samsungtv(hass, MOCK_CONFIG) assert await hass.services.async_call( DOMAIN, SERVICE_MEDIA_PREVIOUS_TRACK, {ATTR_ENTITY_ID: ENTITY_ID}, True ) # key and update called assert remote.control....
[ "async", "def", "test_media_previous_track", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "assert", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_MEDIA_PREVIOUS_TRACK", ...
[ 659, 0 ]
[ 669, 50 ]
python
en
['en', 'en', 'en']
True
test_turn_on_with_turnon
(hass, remote, delay)
Test turn on.
Test turn on.
async def test_turn_on_with_turnon(hass, remote, delay): """Test turn on.""" await setup_samsungtv(hass, MOCK_CONFIG) assert await hass.services.async_call( DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_ID}, True ) assert delay.call_count == 1
[ "async", "def", "test_turn_on_with_turnon", "(", "hass", ",", "remote", ",", "delay", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "assert", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_TURN_O...
[ 672, 0 ]
[ 678, 32 ]
python
en
['en', 'et', 'en']
True
test_turn_on_wol
(hass, remotews)
Test turn on.
Test turn on.
async def test_turn_on_wol(hass, remotews): """Test turn on.""" entry = MockConfigEntry( domain=SAMSUNGTV_DOMAIN, data=MOCK_ENTRY_WS_WITH_MAC, unique_id="any", ) entry.add_to_hass(hass) assert await async_setup_component(hass, SAMSUNGTV_DOMAIN, {}) await hass.async_block_...
[ "async", "def", "test_turn_on_wol", "(", "hass", ",", "remotews", ")", ":", "entry", "=", "MockConfigEntry", "(", "domain", "=", "SAMSUNGTV_DOMAIN", ",", "data", "=", "MOCK_ENTRY_WS_WITH_MAC", ",", "unique_id", "=", "\"any\"", ",", ")", "entry", ".", "add_to_h...
[ 681, 0 ]
[ 698, 40 ]
python
en
['en', 'et', 'en']
True
test_turn_on_without_turnon
(hass, remote)
Test turn on.
Test turn on.
async def test_turn_on_without_turnon(hass, remote): """Test turn on.""" await setup_samsungtv(hass, MOCK_CONFIG_NOTURNON) assert await hass.services.async_call( DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_ID_NOTURNON}, True ) # nothing called as not supported feature assert remote....
[ "async", "def", "test_turn_on_without_turnon", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG_NOTURNON", ")", "assert", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_TURN_ON", ...
[ 701, 0 ]
[ 708, 41 ]
python
en
['en', 'et', 'en']
True
test_play_media
(hass, remote)
Test for play_media.
Test for play_media.
async def test_play_media(hass, remote): """Test for play_media.""" asyncio_sleep = asyncio.sleep sleeps = [] async def sleep(duration, loop): sleeps.append(duration) await asyncio_sleep(0, loop=loop) await setup_samsungtv(hass, MOCK_CONFIG) with patch("asyncio.sleep", new=slee...
[ "async", "def", "test_play_media", "(", "hass", ",", "remote", ")", ":", "asyncio_sleep", "=", "asyncio", ".", "sleep", "sleeps", "=", "[", "]", "async", "def", "sleep", "(", "duration", ",", "loop", ")", ":", "sleeps", ".", "append", "(", "duration", ...
[ 711, 0 ]
[ 742, 31 ]
python
en
['en', 'en', 'en']
True
test_play_media_invalid_type
(hass, remote)
Test for play_media with invalid media type.
Test for play_media with invalid media type.
async def test_play_media_invalid_type(hass, remote): """Test for play_media with invalid media type.""" with patch("homeassistant.components.samsungtv.bridge.Remote") as remote: url = "https://example.com" await setup_samsungtv(hass, MOCK_CONFIG) remote.reset_mock() assert await...
[ "async", "def", "test_play_media_invalid_type", "(", "hass", ",", "remote", ")", ":", "with", "patch", "(", "\"homeassistant.components.samsungtv.bridge.Remote\"", ")", "as", "remote", ":", "url", "=", "\"https://example.com\"", "await", "setup_samsungtv", "(", "hass", ...
[ 745, 0 ]
[ 764, 37 ]
python
en
['en', 'en', 'en']
True
test_play_media_channel_as_string
(hass, remote)
Test for play_media with invalid channel as string.
Test for play_media with invalid channel as string.
async def test_play_media_channel_as_string(hass, remote): """Test for play_media with invalid channel as string.""" with patch("homeassistant.components.samsungtv.bridge.Remote") as remote: url = "https://example.com" await setup_samsungtv(hass, MOCK_CONFIG) remote.reset_mock() ...
[ "async", "def", "test_play_media_channel_as_string", "(", "hass", ",", "remote", ")", ":", "with", "patch", "(", "\"homeassistant.components.samsungtv.bridge.Remote\"", ")", "as", "remote", ":", "url", "=", "\"https://example.com\"", "await", "setup_samsungtv", "(", "ha...
[ 767, 0 ]
[ 786, 37 ]
python
en
['en', 'en', 'en']
True
test_play_media_channel_as_non_positive
(hass, remote)
Test for play_media with invalid channel as non positive integer.
Test for play_media with invalid channel as non positive integer.
async def test_play_media_channel_as_non_positive(hass, remote): """Test for play_media with invalid channel as non positive integer.""" with patch("homeassistant.components.samsungtv.bridge.Remote") as remote: await setup_samsungtv(hass, MOCK_CONFIG) remote.reset_mock() assert await has...
[ "async", "def", "test_play_media_channel_as_non_positive", "(", "hass", ",", "remote", ")", ":", "with", "patch", "(", "\"homeassistant.components.samsungtv.bridge.Remote\"", ")", "as", "remote", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "...
[ 789, 0 ]
[ 807, 37 ]
python
en
['en', 'en', 'en']
True
test_select_source
(hass, remote)
Test for select_source.
Test for select_source.
async def test_select_source(hass, remote): """Test for select_source.""" await setup_samsungtv(hass, MOCK_CONFIG) assert await hass.services.async_call( DOMAIN, SERVICE_SELECT_SOURCE, {ATTR_ENTITY_ID: ENTITY_ID, ATTR_INPUT_SOURCE: "HDMI"}, True, ) # key and update ca...
[ "async", "def", "test_select_source", "(", "hass", ",", "remote", ")", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "assert", "await", "hass", ".", "services", ".", "async_call", "(", "DOMAIN", ",", "SERVICE_SELECT_SOURCE", ",", "{", ...
[ 810, 0 ]
[ 823, 50 ]
python
en
['en', 'en', 'en']
True
test_select_source_invalid_source
(hass, remote)
Test for select_source with invalid source.
Test for select_source with invalid source.
async def test_select_source_invalid_source(hass, remote): """Test for select_source with invalid source.""" with patch("homeassistant.components.samsungtv.bridge.Remote") as remote: await setup_samsungtv(hass, MOCK_CONFIG) remote.reset_mock() assert await hass.services.async_call( ...
[ "async", "def", "test_select_source_invalid_source", "(", "hass", ",", "remote", ")", ":", "with", "patch", "(", "\"homeassistant.components.samsungtv.bridge.Remote\"", ")", "as", "remote", ":", "await", "setup_samsungtv", "(", "hass", ",", "MOCK_CONFIG", ")", "remote...
[ 826, 0 ]
[ 840, 37 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Lutron lights.
Set up the Lutron lights.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Lutron lights.""" devs = [] for (area_name, device) in hass.data[LUTRON_DEVICES]["light"]: dev = LutronLight(area_name, device, hass.data[LUTRON_CONTROLLER]) devs.append(dev) add_entities(devs, True)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "devs", "=", "[", "]", "for", "(", "area_name", ",", "device", ")", "in", "hass", ".", "data", "[", "LUTRON_DEVICES", "]", "[", "\"l...
[ 10, 0 ]
[ 17, 28 ]
python
en
['en', 'ceb', 'en']
True
to_lutron_level
(level)
Convert the given Home Assistant light level (0-255) to Lutron (0.0-100.0).
Convert the given Home Assistant light level (0-255) to Lutron (0.0-100.0).
def to_lutron_level(level): """Convert the given Home Assistant light level (0-255) to Lutron (0.0-100.0).""" return float((level * 100) / 255)
[ "def", "to_lutron_level", "(", "level", ")", ":", "return", "float", "(", "(", "level", "*", "100", ")", "/", "255", ")" ]
[ 20, 0 ]
[ 22, 37 ]
python
en
['en', 'en', 'en']
True
to_hass_level
(level)
Convert the given Lutron (0.0-100.0) light level to Home Assistant (0-255).
Convert the given Lutron (0.0-100.0) light level to Home Assistant (0-255).
def to_hass_level(level): """Convert the given Lutron (0.0-100.0) light level to Home Assistant (0-255).""" return int((level * 255) / 100)
[ "def", "to_hass_level", "(", "level", ")", ":", "return", "int", "(", "(", "level", "*", "255", ")", "/", "100", ")" ]
[ 25, 0 ]
[ 27, 35 ]
python
en
['en', 'en', 'en']
True
LutronLight.__init__
(self, area_name, lutron_device, controller)
Initialize the light.
Initialize the light.
def __init__(self, area_name, lutron_device, controller): """Initialize the light.""" self._prev_brightness = None super().__init__(area_name, lutron_device, controller)
[ "def", "__init__", "(", "self", ",", "area_name", ",", "lutron_device", ",", "controller", ")", ":", "self", ".", "_prev_brightness", "=", "None", "super", "(", ")", ".", "__init__", "(", "area_name", ",", "lutron_device", ",", "controller", ")" ]
[ 33, 4 ]
[ 36, 62 ]
python
en
['en', 'en', 'en']
True
LutronLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return SUPPORT_BRIGHTNESS
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_BRIGHTNESS" ]
[ 39, 4 ]
[ 41, 33 ]
python
en
['da', 'en', 'en']
True
LutronLight.brightness
(self)
Return the brightness of the light.
Return the brightness of the light.
def brightness(self): """Return the brightness of the light.""" new_brightness = to_hass_level(self._lutron_device.last_level()) if new_brightness != 0: self._prev_brightness = new_brightness return new_brightness
[ "def", "brightness", "(", "self", ")", ":", "new_brightness", "=", "to_hass_level", "(", "self", ".", "_lutron_device", ".", "last_level", "(", ")", ")", "if", "new_brightness", "!=", "0", ":", "self", ".", "_prev_brightness", "=", "new_brightness", "return", ...
[ 44, 4 ]
[ 49, 29 ]
python
en
['en', 'no', 'en']
True
LutronLight.turn_on
(self, **kwargs)
Turn the light on.
Turn the light on.
def turn_on(self, **kwargs): """Turn the light on.""" if ATTR_BRIGHTNESS in kwargs and self._lutron_device.is_dimmable: brightness = kwargs[ATTR_BRIGHTNESS] elif self._prev_brightness == 0: brightness = 255 / 2 else: brightness = self._prev_brightness ...
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "ATTR_BRIGHTNESS", "in", "kwargs", "and", "self", ".", "_lutron_device", ".", "is_dimmable", ":", "brightness", "=", "kwargs", "[", "ATTR_BRIGHTNESS", "]", "elif", "self", ".", "_prev_...
[ 51, 4 ]
[ 60, 63 ]
python
en
['en', 'et', 'en']
True
LutronLight.turn_off
(self, **kwargs)
Turn the light off.
Turn the light off.
def turn_off(self, **kwargs): """Turn the light off.""" self._lutron_device.level = 0
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_lutron_device", ".", "level", "=", "0" ]
[ 62, 4 ]
[ 64, 37 ]
python
en
['en', 'zh', 'en']
True
LutronLight.extra_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def extra_state_attributes(self): """Return the state attributes.""" return {"lutron_integration_id": self._lutron_device.id}
[ "def", "extra_state_attributes", "(", "self", ")", ":", "return", "{", "\"lutron_integration_id\"", ":", "self", ".", "_lutron_device", ".", "id", "}" ]
[ 67, 4 ]
[ 69, 64 ]
python
en
['en', 'en', 'en']
True
LutronLight.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self): """Return true if device is on.""" return self._lutron_device.last_level() > 0
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_lutron_device", ".", "last_level", "(", ")", ">", "0" ]
[ 72, 4 ]
[ 74, 51 ]
python
en
['en', 'fy', 'en']
True
LutronLight.update
(self)
Call when forcing a refresh of the device.
Call when forcing a refresh of the device.
def update(self): """Call when forcing a refresh of the device.""" if self._prev_brightness is None: self._prev_brightness = to_hass_level(self._lutron_device.level)
[ "def", "update", "(", "self", ")", ":", "if", "self", ".", "_prev_brightness", "is", "None", ":", "self", ".", "_prev_brightness", "=", "to_hass_level", "(", "self", ".", "_lutron_device", ".", "level", ")" ]
[ 76, 4 ]
[ 79, 76 ]
python
en
['en', 'en', 'en']
True
rot90
(m, k=1, axes=(0, 1))
Rotate an array by 90 degrees in the plane specified by axes. Rotation direction is from the first towards the second axis. Parameters ---------- m : array_like Array of two or more dimensions. k : integer Number of times the array is rotated by 90 degrees. axes: (2,) arra...
Rotate an array by 90 degrees in the plane specified by axes.
def rot90(m, k=1, axes=(0, 1)): """ Rotate an array by 90 degrees in the plane specified by axes. Rotation direction is from the first towards the second axis. Parameters ---------- m : array_like Array of two or more dimensions. k : integer Number of times the array is rot...
[ "def", "rot90", "(", "m", ",", "k", "=", "1", ",", "axes", "=", "(", "0", ",", "1", ")", ")", ":", "axes", "=", "tuple", "(", "axes", ")", "if", "len", "(", "axes", ")", "!=", "2", ":", "raise", "ValueError", "(", "\"len(axes) must be 2.\"", ")...
[ 59, 0 ]
[ 142, 53 ]
python
en
['en', 'error', 'th']
False
flip
(m, axis=None)
Reverse the order of elements in an array along the given axis. The shape of the array is preserved, but the elements are reordered. .. versionadded:: 1.12.0 Parameters ---------- m : array_like Input array. axis : None or int or tuple of ints, optional Axis or axes alon...
Reverse the order of elements in an array along the given axis.
def flip(m, axis=None): """ Reverse the order of elements in an array along the given axis. The shape of the array is preserved, but the elements are reordered. .. versionadded:: 1.12.0 Parameters ---------- m : array_like Input array. axis : None or int or tuple of ints, opti...
[ "def", "flip", "(", "m", ",", "axis", "=", "None", ")", ":", "if", "not", "hasattr", "(", "m", ",", "'ndim'", ")", ":", "m", "=", "asarray", "(", "m", ")", "if", "axis", "is", "None", ":", "indexer", "=", "(", "np", ".", "s_", "[", ":", ":"...
[ 150, 0 ]
[ 240, 21 ]
python
en
['en', 'error', 'th']
False
iterable
(y)
Check whether or not an object can be iterated over. Parameters ---------- y : object Input object. Returns ------- b : bool Return ``True`` if the object has an iterator method or is a sequence and ``False`` otherwise. Examples -------- >>> np.iterable([1,...
Check whether or not an object can be iterated over.
def iterable(y): """ Check whether or not an object can be iterated over. Parameters ---------- y : object Input object. Returns ------- b : bool Return ``True`` if the object has an iterator method or is a sequence and ``False`` otherwise. Examples --------...
[ "def", "iterable", "(", "y", ")", ":", "try", ":", "iter", "(", "y", ")", "except", "TypeError", ":", "return", "False", "return", "True" ]
[ 244, 0 ]
[ 272, 15 ]
python
en
['en', 'error', 'th']
False
average
(a, axis=None, weights=None, returned=False)
Compute the weighted average along the specified axis. Parameters ---------- a : array_like Array containing data to be averaged. If `a` is not an array, a conversion is attempted. axis : None or int or tuple of ints, optional Axis or axes along which to average `a`. The d...
Compute the weighted average along the specified axis.
def average(a, axis=None, weights=None, returned=False): """ Compute the weighted average along the specified axis. Parameters ---------- a : array_like Array containing data to be averaged. If `a` is not an array, a conversion is attempted. axis : None or int or tuple of ints, ...
[ "def", "average", "(", "a", ",", "axis", "=", "None", ",", "weights", "=", "None", ",", "returned", "=", "False", ")", ":", "a", "=", "np", ".", "asanyarray", "(", "a", ")", "if", "weights", "is", "None", ":", "avg", "=", "a", ".", "mean", "(",...
[ 280, 0 ]
[ 418, 18 ]
python
en
['en', 'error', 'th']
False
asarray_chkfinite
(a, dtype=None, order=None)
Convert the input to an array, checking for NaNs or Infs. Parameters ---------- a : array_like Input data, in any form that can be converted to an array. This includes lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays. Success requires no NaNs or Infs....
Convert the input to an array, checking for NaNs or Infs.
def asarray_chkfinite(a, dtype=None, order=None): """Convert the input to an array, checking for NaNs or Infs. Parameters ---------- a : array_like Input data, in any form that can be converted to an array. This includes lists, lists of tuples, tuples, tuples of tuples, tuples ...
[ "def", "asarray_chkfinite", "(", "a", ",", "dtype", "=", "None", ",", "order", "=", "None", ")", ":", "a", "=", "asarray", "(", "a", ",", "dtype", "=", "dtype", ",", "order", "=", "order", ")", "if", "a", ".", "dtype", ".", "char", "in", "typecod...
[ 422, 0 ]
[ 486, 12 ]
python
en
['en', 'en', 'en']
True
piecewise
(x, condlist, funclist, *args, **kw)
Evaluate a piecewise-defined function. Given a set of conditions and corresponding functions, evaluate each function on the input data wherever its condition is true. Parameters ---------- x : ndarray or scalar The input domain. condlist : list of bool arrays or bool scalars ...
Evaluate a piecewise-defined function.
def piecewise(x, condlist, funclist, *args, **kw): """ Evaluate a piecewise-defined function. Given a set of conditions and corresponding functions, evaluate each function on the input data wherever its condition is true. Parameters ---------- x : ndarray or scalar The input domain...
[ "def", "piecewise", "(", "x", ",", "condlist", ",", "funclist", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "x", "=", "asanyarray", "(", "x", ")", "n2", "=", "len", "(", "funclist", ")", "# undocumented: single condition is promoted to a list of one con...
[ 497, 0 ]
[ 615, 12 ]
python
en
['en', 'error', 'th']
False
select
(condlist, choicelist, default=0)
Return an array drawn from elements in choicelist, depending on conditions. Parameters ---------- condlist : list of bool ndarrays The list of conditions which determine from which array in `choicelist` the output elements are taken. When multiple conditions are satisfied, the ...
Return an array drawn from elements in choicelist, depending on conditions.
def select(condlist, choicelist, default=0): """ Return an array drawn from elements in choicelist, depending on conditions. Parameters ---------- condlist : list of bool ndarrays The list of conditions which determine from which array in `choicelist` the output elements are taken. ...
[ "def", "select", "(", "condlist", ",", "choicelist", ",", "default", "=", "0", ")", ":", "# Check the size of condlist and choicelist are the same, or abort.", "if", "len", "(", "condlist", ")", "!=", "len", "(", "choicelist", ")", ":", "raise", "ValueError", "(",...
[ 624, 0 ]
[ 706, 17 ]
python
en
['en', 'error', 'th']
False
copy
(a, order='K', subok=False)
Return an array copy of the given object. Parameters ---------- a : array_like Input data. order : {'C', 'F', 'A', 'K'}, optional Controls the memory layout of the copy. 'C' means C-order, 'F' means F-order, 'A' means 'F' if `a` is Fortran contiguous, 'C' otherwise....
Return an array copy of the given object.
def copy(a, order='K', subok=False): """ Return an array copy of the given object. Parameters ---------- a : array_like Input data. order : {'C', 'F', 'A', 'K'}, optional Controls the memory layout of the copy. 'C' means C-order, 'F' means F-order, 'A' means 'F' if `a` i...
[ "def", "copy", "(", "a", ",", "order", "=", "'K'", ",", "subok", "=", "False", ")", ":", "return", "array", "(", "a", ",", "order", "=", "order", ",", "subok", "=", "subok", ",", "copy", "=", "True", ")" ]
[ 714, 0 ]
[ 791, 56 ]
python
en
['en', 'error', 'th']
False
gradient
(f, *varargs, axis=None, edge_order=1)
Return the gradient of an N-dimensional array. The gradient is computed using second order accurate central differences in the interior points and either first or second order accurate one-sides (forward or backwards) differences at the boundaries. The returned gradient hence has the same shape as...
Return the gradient of an N-dimensional array.
def gradient(f, *varargs, axis=None, edge_order=1): """ Return the gradient of an N-dimensional array. The gradient is computed using second order accurate central differences in the interior points and either first or second order accurate one-sides (forward or backwards) differences at the bounda...
[ "def", "gradient", "(", "f", ",", "*", "varargs", ",", "axis", "=", "None", ",", "edge_order", "=", "1", ")", ":", "f", "=", "np", ".", "asanyarray", "(", "f", ")", "N", "=", "f", ".", "ndim", "# number of dimensions", "if", "axis", "is", "None", ...
[ 802, 0 ]
[ 1144, 22 ]
python
en
['en', 'error', 'th']
False
diff
(a, n=1, axis=-1, prepend=np._NoValue, append=np._NoValue)
Calculate the n-th discrete difference along the given axis. The first difference is given by ``out[i] = a[i+1] - a[i]`` along the given axis, higher differences are calculated by using `diff` recursively. Parameters ---------- a : array_like Input array n : int, optional ...
Calculate the n-th discrete difference along the given axis.
def diff(a, n=1, axis=-1, prepend=np._NoValue, append=np._NoValue): """ Calculate the n-th discrete difference along the given axis. The first difference is given by ``out[i] = a[i+1] - a[i]`` along the given axis, higher differences are calculated by using `diff` recursively. Parameters -...
[ "def", "diff", "(", "a", ",", "n", "=", "1", ",", "axis", "=", "-", "1", ",", "prepend", "=", "np", ".", "_NoValue", ",", "append", "=", "np", ".", "_NoValue", ")", ":", "if", "n", "==", "0", ":", "return", "a", "if", "n", "<", "0", ":", ...
[ 1152, 0 ]
[ 1281, 12 ]
python
en
['en', 'error', 'th']
False
interp
(x, xp, fp, left=None, right=None, period=None)
One-dimensional linear interpolation. Returns the one-dimensional piecewise linear interpolant to a function with given discrete data points (`xp`, `fp`), evaluated at `x`. Parameters ---------- x : array_like The x-coordinates at which to evaluate the interpolated values. xp : 1...
One-dimensional linear interpolation.
def interp(x, xp, fp, left=None, right=None, period=None): """ One-dimensional linear interpolation. Returns the one-dimensional piecewise linear interpolant to a function with given discrete data points (`xp`, `fp`), evaluated at `x`. Parameters ---------- x : array_like The x-coo...
[ "def", "interp", "(", "x", ",", "xp", ",", "fp", ",", "left", "=", "None", ",", "right", "=", "None", ",", "period", "=", "None", ")", ":", "fp", "=", "np", ".", "asarray", "(", "fp", ")", "if", "np", ".", "iscomplexobj", "(", "fp", ")", ":",...
[ 1289, 0 ]
[ 1422, 46 ]
python
en
['en', 'error', 'th']
False
angle
(z, deg=False)
Return the angle of the complex argument. Parameters ---------- z : array_like A complex number or sequence of complex numbers. deg : bool, optional Return angle in degrees if True, radians if False (default). Returns ------- angle : ndarray or scalar The count...
Return the angle of the complex argument.
def angle(z, deg=False): """ Return the angle of the complex argument. Parameters ---------- z : array_like A complex number or sequence of complex numbers. deg : bool, optional Return angle in degrees if True, radians if False (default). Returns ------- angle : nda...
[ "def", "angle", "(", "z", ",", "deg", "=", "False", ")", ":", "z", "=", "asanyarray", "(", "z", ")", "if", "issubclass", "(", "z", ".", "dtype", ".", "type", ",", "_nx", ".", "complexfloating", ")", ":", "zimag", "=", "z", ".", "imag", "zreal", ...
[ 1430, 0 ]
[ 1479, 12 ]
python
en
['en', 'error', 'th']
False
unwrap
(p, discont=pi, axis=-1)
Unwrap by changing deltas between values to 2*pi complement. Unwrap radian phase `p` by changing absolute jumps greater than `discont` to their 2*pi complement along the given axis. Parameters ---------- p : array_like Input array. discont : float, optional Maximum discont...
Unwrap by changing deltas between values to 2*pi complement.
def unwrap(p, discont=pi, axis=-1): """ Unwrap by changing deltas between values to 2*pi complement. Unwrap radian phase `p` by changing absolute jumps greater than `discont` to their 2*pi complement along the given axis. Parameters ---------- p : array_like Input array. discon...
[ "def", "unwrap", "(", "p", ",", "discont", "=", "pi", ",", "axis", "=", "-", "1", ")", ":", "p", "=", "asarray", "(", "p", ")", "nd", "=", "p", ".", "ndim", "dd", "=", "diff", "(", "p", ",", "axis", "=", "axis", ")", "slice1", "=", "[", "...
[ 1487, 0 ]
[ 1540, 13 ]
python
en
['en', 'error', 'th']
False
sort_complex
(a)
Sort a complex array using the real part first, then the imaginary part. Parameters ---------- a : array_like Input array Returns ------- out : complex ndarray Always returns a sorted complex array. Examples -------- >>> np.sort_complex([5, 3, 6, 2, 1]) ar...
Sort a complex array using the real part first, then the imaginary part.
def sort_complex(a): """ Sort a complex array using the real part first, then the imaginary part. Parameters ---------- a : array_like Input array Returns ------- out : complex ndarray Always returns a sorted complex array. Examples -------- >>> np.sort_com...
[ "def", "sort_complex", "(", "a", ")", ":", "b", "=", "array", "(", "a", ",", "copy", "=", "True", ")", "b", ".", "sort", "(", ")", "if", "not", "issubclass", "(", "b", ".", "dtype", ".", "type", ",", "_nx", ".", "complexfloating", ")", ":", "if...
[ 1548, 0 ]
[ 1581, 16 ]
python
en
['en', 'error', 'th']
False
trim_zeros
(filt, trim='fb')
Trim the leading and/or trailing zeros from a 1-D array or sequence. Parameters ---------- filt : 1-D array or sequence Input array. trim : str, optional A string with 'f' representing trim from front and 'b' to trim from back. Default is 'fb', trim zeros from both front an...
Trim the leading and/or trailing zeros from a 1-D array or sequence.
def trim_zeros(filt, trim='fb'): """ Trim the leading and/or trailing zeros from a 1-D array or sequence. Parameters ---------- filt : 1-D array or sequence Input array. trim : str, optional A string with 'f' representing trim from front and 'b' to trim from back. Defaul...
[ "def", "trim_zeros", "(", "filt", ",", "trim", "=", "'fb'", ")", ":", "first", "=", "0", "trim", "=", "trim", ".", "upper", "(", ")", "if", "'F'", "in", "trim", ":", "for", "i", "in", "filt", ":", "if", "i", "!=", "0.", ":", "break", "else", ...
[ 1589, 0 ]
[ 1637, 27 ]
python
en
['en', 'error', 'th']
False
extract
(condition, arr)
Return the elements of an array that satisfy some condition. This is equivalent to ``np.compress(ravel(condition), ravel(arr))``. If `condition` is boolean ``np.extract`` is equivalent to ``arr[condition]``. Note that `place` does the exact opposite of `extract`. Parameters ---------- c...
Return the elements of an array that satisfy some condition.
def extract(condition, arr): """ Return the elements of an array that satisfy some condition. This is equivalent to ``np.compress(ravel(condition), ravel(arr))``. If `condition` is boolean ``np.extract`` is equivalent to ``arr[condition]``. Note that `place` does the exact opposite of `extract`. ...
[ "def", "extract", "(", "condition", ",", "arr", ")", ":", "return", "_nx", ".", "take", "(", "ravel", "(", "arr", ")", ",", "nonzero", "(", "ravel", "(", "condition", ")", ")", "[", "0", "]", ")" ]
[ 1645, 0 ]
[ 1693, 61 ]
python
en
['en', 'error', 'th']
False
place
(arr, mask, vals)
Change elements of an array based on conditional and input values. Similar to ``np.copyto(arr, vals, where=mask)``, the difference is that `place` uses the first N elements of `vals`, where N is the number of True values in `mask`, while `copyto` uses the elements where `mask` is True. Note t...
Change elements of an array based on conditional and input values.
def place(arr, mask, vals): """ Change elements of an array based on conditional and input values. Similar to ``np.copyto(arr, vals, where=mask)``, the difference is that `place` uses the first N elements of `vals`, where N is the number of True values in `mask`, while `copyto` uses the elements wh...
[ "def", "place", "(", "arr", ",", "mask", ",", "vals", ")", ":", "if", "not", "isinstance", "(", "arr", ",", "np", ".", "ndarray", ")", ":", "raise", "TypeError", "(", "\"argument 1 must be numpy.ndarray, \"", "\"not {name}\"", ".", "format", "(", "name", "...
[ 1701, 0 ]
[ 1741, 35 ]
python
en
['en', 'error', 'th']
False
disp
(mesg, device=None, linefeed=True)
Display a message on a device. Parameters ---------- mesg : str Message to display. device : object Device to write message. If None, defaults to ``sys.stdout`` which is very similar to ``print``. `device` needs to have ``write()`` and ``flush()`` methods. linef...
Display a message on a device.
def disp(mesg, device=None, linefeed=True): """ Display a message on a device. Parameters ---------- mesg : str Message to display. device : object Device to write message. If None, defaults to ``sys.stdout`` which is very similar to ``print``. `device` needs to have ``w...
[ "def", "disp", "(", "mesg", ",", "device", "=", "None", ",", "linefeed", "=", "True", ")", ":", "if", "device", "is", "None", ":", "device", "=", "sys", ".", "stdout", "if", "linefeed", ":", "device", ".", "write", "(", "'%s\\n'", "%", "mesg", ")",...
[ 1744, 0 ]
[ 1783, 10 ]
python
en
['en', 'error', 'th']
False
_parse_gufunc_signature
(signature)
Parse string signatures for a generalized universal function. Arguments --------- signature : string Generalized universal function signature, e.g., ``(m,n),(n,p)->(m,p)`` for ``np.matmul``. Returns ------- Tuple of input and output core dimensions parsed from the signatur...
Parse string signatures for a generalized universal function.
def _parse_gufunc_signature(signature): """ Parse string signatures for a generalized universal function. Arguments --------- signature : string Generalized universal function signature, e.g., ``(m,n),(n,p)->(m,p)`` for ``np.matmul``. Returns ------- Tuple of input and ...
[ "def", "_parse_gufunc_signature", "(", "signature", ")", ":", "if", "not", "re", ".", "match", "(", "_SIGNATURE", ",", "signature", ")", ":", "raise", "ValueError", "(", "'not a valid gufunc signature: {}'", ".", "format", "(", "signature", ")", ")", "return", ...
[ 1794, 0 ]
[ 1814, 55 ]
python
en
['en', 'error', 'th']
False
_update_dim_sizes
(dim_sizes, arg, core_dims)
Incrementally check and update core dimension sizes for a single argument. Arguments --------- dim_sizes : Dict[str, int] Sizes of existing core dimensions. Will be updated in-place. arg : ndarray Argument to examine. core_dims : Tuple[str, ...] Core dimensions for this...
Incrementally check and update core dimension sizes for a single argument.
def _update_dim_sizes(dim_sizes, arg, core_dims): """ Incrementally check and update core dimension sizes for a single argument. Arguments --------- dim_sizes : Dict[str, int] Sizes of existing core dimensions. Will be updated in-place. arg : ndarray Argument to examine. cor...
[ "def", "_update_dim_sizes", "(", "dim_sizes", ",", "arg", ",", "core_dims", ")", ":", "if", "not", "core_dims", ":", "return", "num_core_dims", "=", "len", "(", "core_dims", ")", "if", "arg", ".", "ndim", "<", "num_core_dims", ":", "raise", "ValueError", "...
[ 1817, 0 ]
[ 1848, 33 ]
python
en
['en', 'error', 'th']
False