_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q19600 | Utils.wait_until_element_stops | train | def wait_until_element_stops(self, element, times=1000, timeout=None):
"""Search element and wait until it has stopped moving
:param element: PageElement or element locator as a tuple (locator_type, locator_value) to be found
:param times: number of iterations checking the element's location th... | python | {
"resource": ""
} |
q19601 | Utils.wait_until_element_contains_text | train | def wait_until_element_contains_text(self, element, text, timeout=None):
"""Search element and wait until it contains the expected text
:param element: PageElement or element locator as a tuple (locator_type, locator_value) to be found
:param text: text expected to be contained into the element... | python | {
"resource": ""
} |
q19602 | Utils.wait_until_element_not_contain_text | train | def wait_until_element_not_contain_text(self, element, text, timeout=None):
"""Search element and wait until it does not contain the expected text
:param element: PageElement or element locator as a tuple (locator_type, locator_value) to be found
:param text: text expected to be contained into ... | python | {
"resource": ""
} |
q19603 | Utils.wait_until_element_attribute_is | train | def wait_until_element_attribute_is(self, element, attribute, value, timeout=None):
"""Search element and wait until the requested attribute contains the expected value
:param element: PageElement or element locator as a tuple (locator_type, locator_value) to be found
:param attribute: attribut... | python | {
"resource": ""
} |
q19604 | Utils.get_remote_node | train | def get_remote_node(self):
"""Return the remote node that it's executing the actual test session
:returns: tuple with server type (local, grid, ggr, selenium) and remote node name
"""
logging.getLogger("requests").setLevel(logging.WARNING)
remote_node = None
server_type ... | python | {
"resource": ""
} |
q19605 | Utils.get_server_url | train | def get_server_url(self):
"""Return the configured server url
:returns: server url
"""
server_host = self.driver_wrapper.config.get('Server', 'host')
server_port = self.driver_wrapper.config.get('Server', 'port')
server_username = self.driver_wrapper.config.get_optional(... | python | {
"resource": ""
} |
q19606 | Utils.download_remote_video | train | def download_remote_video(self, remote_node, session_id, video_name):
"""Download the video recorded in the remote node during the specified test session and save it in videos folder
:param remote_node: remote node name
:param session_id: test session id
:param video_name: video name
... | python | {
"resource": ""
} |
q19607 | Utils._get_remote_node_url | train | def _get_remote_node_url(self, remote_node):
"""Get grid-extras url of a node
:param remote_node: remote node name
:returns: grid-extras url
"""
logging.getLogger("requests").setLevel(logging.WARNING)
gridextras_port = 3000
return 'http://{}:{}'.format(remote_nod... | python | {
"resource": ""
} |
q19608 | Utils._get_remote_video_url | train | def _get_remote_video_url(self, remote_node, session_id):
"""Get grid-extras url to download videos
:param remote_node: remote node name
:param session_id: test session id
:returns: grid-extras url to download videos
"""
url = '{}/video'.format(self._get_remote_node_url(... | python | {
"resource": ""
} |
q19609 | Utils._download_video | train | def _download_video(self, video_url, video_name):
"""Download a video from the remote node
:param video_url: video url
:param video_name: video name
"""
filename = '{0:0=2d}_{1}'.format(DriverWrappersPool.videos_number, video_name)
filename = '{}.mp4'.format(get_valid_fi... | python | {
"resource": ""
} |
q19610 | Utils.is_remote_video_enabled | train | def is_remote_video_enabled(self, remote_node):
"""Check if the remote node has the video recorder enabled
:param remote_node: remote node name
:returns: true if it has the video recorder enabled
"""
enabled = False
if remote_node:
url = '{}/config'.format(se... | python | {
"resource": ""
} |
q19611 | Utils.get_center | train | def get_center(self, element):
"""Get center coordinates of an element
:param element: either a WebElement, PageElement or element locator as a tuple (locator_type, locator_value)
:returns: dict with center coordinates
"""
web_element = self.get_web_element(element)
loca... | python | {
"resource": ""
} |
q19612 | Utils.get_safari_navigation_bar_height | train | def get_safari_navigation_bar_height(self):
"""Get the height of Safari navigation bar
:returns: height of navigation bar
"""
status_bar_height = 0
if self.driver_wrapper.is_ios_test() and self.driver_wrapper.is_web_test():
# ios 7.1, 8.3
status_bar_heigh... | python | {
"resource": ""
} |
q19613 | Utils.get_window_size | train | def get_window_size(self):
"""Generic method to get window size using a javascript workaround for Android web tests
:returns: dict with window width and height
"""
if not self._window_size:
if self.driver_wrapper.is_android_web_test() and self.driver_wrapper.driver.current_c... | python | {
"resource": ""
} |
q19614 | Utils.get_native_coords | train | def get_native_coords(self, coords):
"""Convert web coords into native coords. Assumes that the initial context is WEBVIEW and switches to
NATIVE_APP context.
:param coords: dict with web coords, e.g. {'x': 10, 'y': 10}
:returns: dict with native coords
"""
web_window_s... | python | {
"resource": ""
} |
q19615 | Utils.swipe | train | def swipe(self, element, x, y, duration=None):
"""Swipe over an element
:param element: either a WebElement, PageElement or element locator as a tuple (locator_type, locator_value)
:param x: horizontal movement
:param y: vertical movement
:param duration: time to take the swipe,... | python | {
"resource": ""
} |
q19616 | Utils.get_web_element | train | def get_web_element(self, element):
"""Return the web element from a page element or its locator
:param element: either a WebElement, PageElement or element locator as a tuple (locator_type, locator_value)
:returns: WebElement object
"""
from toolium.pageelements.page_element im... | python | {
"resource": ""
} |
q19617 | Utils.get_first_webview_context | train | def get_first_webview_context(self):
"""Return the first WEBVIEW context or raise an exception if it is not found
:returns: first WEBVIEW context
"""
for context in self.driver_wrapper.driver.contexts:
if context.startswith('WEBVIEW'):
return context
... | python | {
"resource": ""
} |
q19618 | DriverWrappersPool.capture_screenshots | train | def capture_screenshots(cls, name):
"""Capture a screenshot in each driver
:param name: screenshot name suffix
"""
screenshot_name = '{}_driver{}' if len(cls.driver_wrappers) > 1 else '{}'
driver_index = 1
for driver_wrapper in cls.driver_wrappers:
if not dri... | python | {
"resource": ""
} |
q19619 | DriverWrappersPool.connect_default_driver_wrapper | train | def connect_default_driver_wrapper(cls, config_files=None):
"""Get default driver wrapper, configure it and connect driver
:param config_files: driver wrapper specific config files
:returns: default driver wrapper
:rtype: toolium.driver_wrapper.DriverWrapper
"""
driver_w... | python | {
"resource": ""
} |
q19620 | DriverWrappersPool.close_drivers | train | def close_drivers(cls, scope, test_name, test_passed=True, context=None):
"""Stop all drivers, capture screenshots, copy webdriver and GGR logs and download saved videos
:param scope: execution scope (function, module, class or session)
:param test_name: executed test name
:param test_p... | python | {
"resource": ""
} |
q19621 | DriverWrappersPool.stop_drivers | train | def stop_drivers(cls, maintain_default=False):
"""Stop all drivers except default if it should be reused
:param maintain_default: True if the default driver should not be closed
"""
# Exclude first wrapper if the driver must be reused
driver_wrappers = cls.driver_wrappers[1:] if... | python | {
"resource": ""
} |
q19622 | DriverWrappersPool.download_videos | train | def download_videos(cls, name, test_passed=True, maintain_default=False):
"""Download saved videos if video is enabled or if test fails
:param name: destination file name
:param test_passed: True if the test has passed
:param maintain_default: True if the default driver should not be cl... | python | {
"resource": ""
} |
q19623 | DriverWrappersPool.save_all_webdriver_logs | train | def save_all_webdriver_logs(cls, test_name, test_passed):
"""Get all webdriver logs of each driver and write them to log files
:param test_name: test that has generated these logs
:param test_passed: True if the test has passed
"""
log_name = '{} [driver {}]' if len(cls.driver_w... | python | {
"resource": ""
} |
q19624 | DriverWrappersPool.save_all_ggr_logs | train | def save_all_ggr_logs(cls, test_name, test_passed):
"""Get all GGR logs of each driver and write them to log files
:param test_name: test that has generated these logs
:param test_passed: True if the test has passed
"""
log_name = '{} [driver {}]' if len(cls.driver_wrappers) > 1... | python | {
"resource": ""
} |
q19625 | DriverWrappersPool.get_configured_value | train | def get_configured_value(system_property_name, specific_value, default_value):
"""Get configured value from system properties, method parameters or default value
:param system_property_name: system property name
:param specific_value: test case specific value
:param default_value: defau... | python | {
"resource": ""
} |
q19626 | DriverWrappersPool.configure_common_directories | train | def configure_common_directories(cls, tc_config_files):
"""Configure common config and output folders for all tests
:param tc_config_files: test case specific config files
"""
if cls.config_directory is None:
# Get config directory from properties
config_director... | python | {
"resource": ""
} |
q19627 | DriverWrappersPool.get_default_config_directory | train | def get_default_config_directory():
"""Return default config directory, based in the actual test path
:returns: default config directory
"""
test_path = os.path.dirname(os.path.realpath(inspect.getouterframes(inspect.currentframe())[2][1]))
return os.path.join(test_path, 'conf') | python | {
"resource": ""
} |
q19628 | DriverWrappersPool._find_parent_directory | train | def _find_parent_directory(directory, filename):
"""Find a directory in parent tree with a specific filename
:param directory: directory name to find
:param filename: filename to find
:returns: absolute directory path
"""
parent_directory = directory
absolute_dir... | python | {
"resource": ""
} |
q19629 | DriverWrappersPool.configure_visual_directories | train | def configure_visual_directories(cls, driver_info):
"""Configure screenshots, videos and visual directories
:param driver_info: driver property value to name folders
"""
if cls.screenshots_directory is None:
# Unique screenshots and videos directories
date = date... | python | {
"resource": ""
} |
q19630 | DriverWrappersPool.initialize_config_files | train | def initialize_config_files(tc_config_files=None):
"""Initialize config files and update config files names with the environment
:param tc_config_files: test case specific config files
:returns: initialized config files object
"""
# Initialize config files
if tc_config_f... | python | {
"resource": ""
} |
q19631 | before_all | train | def before_all(context):
"""Initialization method that will be executed before the test execution
:param context: behave context
"""
# Use pytest asserts if behave_pytest is installed
install_pytest_asserts()
# Get 'Config_environment' property from user input (e.g. -D Config_environment=ios)
... | python | {
"resource": ""
} |
q19632 | bdd_common_before_scenario | train | def bdd_common_before_scenario(context_or_world, scenario, no_driver=False):
"""Common scenario initialization in behave or lettuce
:param context_or_world: behave context or lettuce world
:param scenario: running scenario
:param no_driver: True if this is an api test and driver should not be started
... | python | {
"resource": ""
} |
q19633 | create_and_configure_wrapper | train | def create_and_configure_wrapper(context_or_world):
"""Create and configure driver wrapper in behave or lettuce tests
:param context_or_world: behave context or lettuce world
"""
# Create default driver wrapper
context_or_world.driver_wrapper = DriverWrappersPool.get_default_wrapper()
context_o... | python | {
"resource": ""
} |
q19634 | connect_wrapper | train | def connect_wrapper(context_or_world):
"""Connect driver in behave or lettuce tests
:param context_or_world: behave context or lettuce world
"""
# Create driver if it is not already created
if context_or_world.driver_wrapper.driver:
context_or_world.driver = context_or_world.driver_wrapper.... | python | {
"resource": ""
} |
q19635 | add_assert_screenshot_methods | train | def add_assert_screenshot_methods(context_or_world, scenario):
"""Add assert screenshot methods to behave or lettuce object
:param context_or_world: behave context or lettuce world
:param scenario: running scenario
"""
file_suffix = scenario.name
def assert_screenshot(element_or_selector, file... | python | {
"resource": ""
} |
q19636 | bdd_common_after_scenario | train | def bdd_common_after_scenario(context_or_world, scenario, status):
"""Clean method that will be executed after each scenario in behave or lettuce
:param context_or_world: behave context or lettuce world
:param scenario: running scenario
:param status: scenario status (passed, failed or skipped)
"""... | python | {
"resource": ""
} |
q19637 | after_feature | train | def after_feature(context, feature):
"""Clean method that will be executed after each feature
:param context: behave context
:param feature: running feature
"""
# Behave dynamic environment
context.dyn_env.execute_after_feature_steps(context)
# Close drivers
DriverWrappersPool.close_dr... | python | {
"resource": ""
} |
q19638 | bdd_common_after_all | train | def bdd_common_after_all(context_or_world):
"""Common after all method in behave or lettuce
:param context_or_world: behave context or lettuce world
"""
# Close drivers
DriverWrappersPool.close_drivers(scope='session', test_name='multiple_tests',
test_passed=con... | python | {
"resource": ""
} |
q19639 | DriverWrapper.configure_logger | train | def configure_logger(self, tc_config_log_filename=None, tc_output_log_filename=None):
"""Configure selenium instance logger
:param tc_config_log_filename: test case specific logging config file
:param tc_output_log_filename: test case specific output logger file
"""
# Get config... | python | {
"resource": ""
} |
q19640 | DriverWrapper.configure_properties | train | def configure_properties(self, tc_config_prop_filenames=None, behave_properties=None):
"""Configure selenium instance properties
:param tc_config_prop_filenames: test case specific properties filenames
:param behave_properties: dict with behave user data properties
"""
prop_file... | python | {
"resource": ""
} |
q19641 | DriverWrapper.configure_visual_baseline | train | def configure_visual_baseline(self):
"""Configure baseline directory"""
# Get baseline name
baseline_name = self.config.get_optional('VisualTests', 'baseline_name', '{Driver_type}')
for section in self.config.sections():
for option in self.config.options(section):
... | python | {
"resource": ""
} |
q19642 | DriverWrapper.update_visual_baseline | train | def update_visual_baseline(self):
"""Configure baseline directory after driver is created"""
# Update baseline with real platformVersion value
if '{PlatformVersion}' in self.baseline_name:
try:
platform_version = self.driver.desired_capabilities['platformVersion']
... | python | {
"resource": ""
} |
q19643 | DriverWrapper.configure | train | def configure(self, tc_config_files, is_selenium_test=True, behave_properties=None):
"""Configure initial selenium instance using logging and properties files for Selenium or Appium tests
:param tc_config_files: test case specific config files
:param is_selenium_test: true if test is a selenium... | python | {
"resource": ""
} |
q19644 | DriverWrapper.connect | train | def connect(self, maximize=True):
"""Set up the selenium driver and connect to the server
:param maximize: True if the driver should be maximized
:returns: selenium driver
"""
if not self.config.get('Driver', 'type') or self.config.get('Driver', 'type') in ['api', 'no_driver']:
... | python | {
"resource": ""
} |
q19645 | DriverWrapper.get_config_window_bounds | train | def get_config_window_bounds(self):
"""Reads bounds from config and, if monitor is specified, modify the values to match with the specified monitor
:return: coords X and Y where set the browser window.
"""
bounds_x = int(self.config.get_optional('Driver', 'bounds_x') or 0)
bound... | python | {
"resource": ""
} |
q19646 | DriverWrapper.should_reuse_driver | train | def should_reuse_driver(self, scope, test_passed, context=None):
"""Check if the driver should be reused
:param scope: execution scope (function, module, class or session)
:param test_passed: True if the test has passed
:param context: behave context
:returns: True if the driver... | python | {
"resource": ""
} |
q19647 | get_long_description | train | def get_long_description():
"""Get README content and update rst urls
:returns: long description
"""
# Get readme content
readme = read_file('README.rst')
# Change rst urls to ReadTheDocs html urls
docs_url = 'http://toolium.readthedocs.org/en/latest'
description = readme.replace('/CHA... | python | {
"resource": ""
} |
q19648 | jira | train | def jira(test_key):
"""Decorator to update test status in Jira
:param test_key: test case key in Jira
:returns: jira test
"""
def decorator(test_item):
def modified_test(*args, **kwargs):
save_jira_conf()
try:
test_item(*args, **kwargs)
e... | python | {
"resource": ""
} |
q19649 | save_jira_conf | train | def save_jira_conf():
"""Read Jira configuration from properties file and save it"""
global enabled, execution_url, summary_prefix, labels, comments, fix_version, build, only_if_changes, attachments
config = DriverWrappersPool.get_default_wrapper().config
enabled = config.getboolean_optional('Jira', 'en... | python | {
"resource": ""
} |
q19650 | add_jira_status | train | def add_jira_status(test_key, test_status, test_comment):
"""Save test status and comments to update Jira later
:param test_key: test case key in Jira
:param test_status: test case status
:param test_comment: test case comments
"""
global attachments
if test_key and enabled:
if test... | python | {
"resource": ""
} |
q19651 | change_jira_status | train | def change_jira_status(test_key, test_status, test_comment, test_attachments):
"""Update test status in Jira
:param test_key: test case key in Jira
:param test_status: test case status
:param test_comment: test case comments
:param test_attachments: test case attachments
"""
logger = loggin... | python | {
"resource": ""
} |
q19652 | get_error_message | train | def get_error_message(response_content):
"""Extract error message from the HTTP response
:param response_content: HTTP response from test case execution API
:returns: error message
"""
apache_regex = re.compile('.*<u>(.*)</u></p><p>.*')
match = apache_regex.search(response_content)
if match... | python | {
"resource": ""
} |
q19653 | Button.click | train | def click(self):
"""Click the element
:returns: page element instance
"""
try:
self.wait_until_clickable().web_element.click()
except StaleElementReferenceException:
# Retry if element has changed
self.web_element.click()
return self | python | {
"resource": ""
} |
q19654 | PageObject._get_page_elements | train | def _get_page_elements(self):
"""Return page elements and page objects of this page object
:returns: list of page elements and page objects
"""
page_elements = []
for attribute, value in list(self.__dict__.items()) + list(self.__class__.__dict__.items()):
if attribut... | python | {
"resource": ""
} |
q19655 | PageObject.wait_until_loaded | train | def wait_until_loaded(self, timeout=None):
"""Wait until page object is loaded
Search all page elements configured with wait=True
:param timeout: max time to wait
:returns: this page object instance
"""
for element in self._get_page_elements():
if hasattr(ele... | python | {
"resource": ""
} |
q19656 | ExtendedConfigParser.get_optional | train | def get_optional(self, section, option, default=None):
""" Get an option value for a given section
If the section or the option are not found, the default value is returned
:param section: config section
:param option: config option
:param default: default value
:returns... | python | {
"resource": ""
} |
q19657 | ExtendedConfigParser.getboolean_optional | train | def getboolean_optional(self, section, option, default=False):
""" Get an option boolean value for a given section
If the section or the option are not found, the default value is returned
:param section: config section
:param option: config option
:param default: default value
... | python | {
"resource": ""
} |
q19658 | ExtendedConfigParser.deepcopy | train | def deepcopy(self):
"""Returns a deep copy of config object
:returns: a copy of the config object
"""
# Save actual config to a string
config_string = StringIO()
self.write(config_string)
# We must reset the buffer ready for reading.
config_string.seek(0... | python | {
"resource": ""
} |
q19659 | ExtendedConfigParser.update_properties | train | def update_properties(self, new_properties):
""" Update config properties values
Property name must be equal to 'Section_option' of config property
:param new_properties: dict with new properties values
"""
[self._update_property_from_dict(section, option, new_properties)
... | python | {
"resource": ""
} |
q19660 | ExtendedConfigParser._update_property_from_dict | train | def _update_property_from_dict(self, section, option, new_properties):
""" Update a config property value with a new property value
Property name must be equal to 'Section_option' of config property
:param section: config section
:param option: config option
:param new_propertie... | python | {
"resource": ""
} |
q19661 | ExtendedConfigParser.get_config_from_file | train | def get_config_from_file(conf_properties_files):
"""Reads properties files and saves them to a config object
:param conf_properties_files: comma-separated list of properties files
:returns: config object
"""
# Initialize the config object
config = ExtendedConfigParser()
... | python | {
"resource": ""
} |
q19662 | PageElements.web_elements | train | def web_elements(self):
"""Find multiple WebElements using element locator
:returns: list of web element objects
:rtype: list of selenium.webdriver.remote.webelement.WebElement
or list of appium.webdriver.webelement.WebElement
"""
if not self._web_elements or not... | python | {
"resource": ""
} |
q19663 | PageElements.page_elements | train | def page_elements(self):
"""Find multiple PageElement using element locator
:returns: list of page element objects
:rtype: list of toolium.pageelements.PageElement
"""
if not self._page_elements or not self.config.getboolean_optional('Driver', 'save_web_element'):
se... | python | {
"resource": ""
} |
q19664 | PageElement.web_element | train | def web_element(self):
"""Find WebElement using element locator
:returns: web element object
:rtype: selenium.webdriver.remote.webelement.WebElement or appium.webdriver.webelement.WebElement
"""
try:
self._find_web_element()
except NoSuchElementException as e... | python | {
"resource": ""
} |
q19665 | PageElement._find_web_element | train | def _find_web_element(self):
"""Find WebElement using element locator and save it in _web_element attribute"""
if not self._web_element or not self.config.getboolean_optional('Driver', 'save_web_element'):
# If the element is encapsulated we use the shadowroot tag in yaml (eg. Shadowroot: ro... | python | {
"resource": ""
} |
q19666 | PageElement.scroll_element_into_view | train | def scroll_element_into_view(self):
"""Scroll element into view
:returns: page element instance
"""
x = self.web_element.location['x']
y = self.web_element.location['y']
self.driver.execute_script('window.scrollTo({0}, {1})'.format(x, y))
return self | python | {
"resource": ""
} |
q19667 | PageElement.assert_screenshot | train | def assert_screenshot(self, filename, threshold=0, exclude_elements=[], force=False):
"""Assert that a screenshot of the element is the same as a screenshot on disk, within a given threshold.
:param filename: the filename for the screenshot, which will be appended with ``.png``
:param threshold... | python | {
"resource": ""
} |
q19668 | InputText.text | train | def text(self, value):
"""Set value on the element
:param value: value to be set
"""
if self.driver_wrapper.is_ios_test() and not self.driver_wrapper.is_web_test():
self.web_element.set_value(value)
elif self.shadowroot:
self.driver.execute_script('return... | python | {
"resource": ""
} |
q19669 | install_documentation | train | def install_documentation(path="./Litho1pt0-Notebooks"):
"""Install the example notebooks for litho1pt0 in the given location
WARNING: If the path exists, the Notebook files will be written into the path
and will overwrite any existing files with which they collide. The default
path ("./Litho1pt0-Noteb... | python | {
"resource": ""
} |
q19670 | remove_duplicates | train | def remove_duplicates(vector_tuple):
"""
Remove duplicates rows from N equally-sized arrays
"""
array = np.column_stack(vector_tuple)
a = np.ascontiguousarray(array)
unique_a = np.unique(a.view([('', a.dtype)]*a.shape[1]))
b = unique_a.view(a.dtype).reshape((unique_a.shape[0], a.shape[1]))
... | python | {
"resource": ""
} |
q19671 | Triangulation._is_collinear | train | def _is_collinear(self, x, y):
"""
Checks if first three points are collinear
"""
pts = np.column_stack([x[:3], y[:3], np.ones(3)])
return np.linalg.det(pts) == 0.0 | python | {
"resource": ""
} |
q19672 | Triangulation._deshuffle_field | train | def _deshuffle_field(self, *args):
"""
Return to original ordering
"""
ip = self._invpermutation
fields = []
for arg in args:
fields.append( arg[ip] )
if len(fields) == 1:
return fields[0]
else:
return fields | python | {
"resource": ""
} |
q19673 | Triangulation.gradient | train | def gradient(self, f, nit=3, tol=1e-3, guarantee_convergence=False):
"""
Return the gradient of an n-dimensional array.
The method consists of minimizing a quadratic functional Q(G) over
gradient vectors (in x and y directions), where Q is an approximation
to the linearized curv... | python | {
"resource": ""
} |
q19674 | Triangulation.gradient_local | train | def gradient_local(self, f, index):
"""
Return the gradient at a specified node.
This routine employs a local method, in which values depend only on nearby
data points, to compute an estimated gradient at a node.
gradient_local() is more efficient than gradient() only if it is ... | python | {
"resource": ""
} |
q19675 | Triangulation.interpolate | train | def interpolate(self, xi, yi, zdata, order=1):
"""
Base class to handle nearest neighbour, linear, and cubic interpolation.
Given a triangulation of a set of nodes and values at the nodes,
this method interpolates the value at the given xi,yi coordinates.
Parameters
----... | python | {
"resource": ""
} |
q19676 | Triangulation.interpolate_nearest | train | def interpolate_nearest(self, xi, yi, zdata):
"""
Nearest-neighbour interpolation.
Calls nearnd to find the index of the closest neighbours to xi,yi
Parameters
----------
xi : float / array of floats, shape (l,)
x coordinates on the Cartesian plane
... | python | {
"resource": ""
} |
q19677 | Triangulation.containing_triangle | train | def containing_triangle(self, xi, yi):
"""
Returns indices of the triangles containing xi yi
Parameters
----------
xi : float / array of floats, shape (l,)
Cartesian coordinates in the x direction
yi : float / array of floats, shape (l,)
Cartesi... | python | {
"resource": ""
} |
q19678 | Triangulation.identify_vertex_neighbours | train | def identify_vertex_neighbours(self, vertex):
"""
Find the neighbour-vertices in the triangulation for the given vertex
Searches self.simplices for vertex entries and sorts neighbours
"""
simplices = self.simplices
ridx, cidx = np.where(simplices == vertex)
neighb... | python | {
"resource": ""
} |
q19679 | Triangulation.identify_vertex_triangles | train | def identify_vertex_triangles(self, vertices):
"""
Find all triangles which own any of the vertices in the list provided
"""
triangles = []
for vertex in np.array(vertices).reshape(-1):
triangles.append(np.where(self.simplices == vertex)[0])
return np.uniqu... | python | {
"resource": ""
} |
q19680 | Triangulation.convex_hull | train | def convex_hull(self):
"""
Find the Convex Hull of the internal set of x,y points.
Returns
-------
bnodes : array of ints
indices corresponding to points on the convex hull
"""
bnodes, nb, na, nt = _tripack.bnodes(self.lst, self.lptr, self.lend, self... | python | {
"resource": ""
} |
q19681 | Triangulation.areas | train | def areas(self):
"""
Compute the area of each triangle within the triangulation of points.
Returns
-------
area : array of floats, shape (nt,)
area of each triangle in self.simplices where nt
is the number of triangles.
"""
v1 = self.poi... | python | {
"resource": ""
} |
q19682 | Triangulation.join | train | def join(self, t2, unique=False):
"""
Join this triangulation with another. If the points are known to have no duplicates, then
set unique=False to skip the testing and duplicate removal
"""
x_v1 = np.concatenate((self.x, t2.x), axis=0)
y_v1 = np.concatenate((self.y, t2.... | python | {
"resource": ""
} |
q19683 | write_processed_litho_data | train | def write_processed_litho_data(filename, litho_data, litho_points):
"""
Ensures that the data is stored in a format which is valid for initialising the class
"""
np.savez_compressed(filename, litho1_all_data=litho_data, litho1_mesh_coords=litho_points)
return | python | {
"resource": ""
} |
q19684 | weighted_average_to_nodes | train | def weighted_average_to_nodes(x1, x2, data, interpolator ):
""" Weighted average of scattered data to the nodal points
of a triangulation using the barycentric coordinates as
weightings.
Parameters
----------
x1, x2 : 1D arrays arrays of x,y or lon, lat (radians)
data : 1D array of data... | python | {
"resource": ""
} |
q19685 | great_circle_Npoints | train | def great_circle_Npoints(lonlat1r, lonlat2r, N):
"""
N points along the line joining lonlat1 and lonlat2
"""
ratio = np.linspace(0.0,1.0, N).reshape(-1,1)
xyz1 = lonlat2xyz(lonlat1r[0], lonlat1r[1])
xyz2 = lonlat2xyz(lonlat2r[0], lonlat2r[1])
mids = ratio * xyz2 + (1.0-ratio) * xyz1
... | python | {
"resource": ""
} |
q19686 | sTriangulation._generate_permutation | train | def _generate_permutation(self, npoints):
"""
Create shuffle and deshuffle vectors
"""
i = np.arange(0, npoints)
# permutation
p = np.random.permutation(npoints)
ip = np.empty_like(p)
# inverse permutation
ip[p[i]] = i
return p, ip | python | {
"resource": ""
} |
q19687 | sTriangulation._is_collinear | train | def _is_collinear(self, lons, lats):
"""
Checks if first three points are collinear - in the spherical
case this corresponds to all points lying on a great circle
and, hence, all coordinate vectors being in a single plane.
"""
x, y, z = lonlat2xyz(lons[:3], lats[:3])
... | python | {
"resource": ""
} |
q19688 | sTriangulation.gradient_xyz | train | def gradient_xyz(self, f, nit=3, tol=1e-3, guarantee_convergence=False):
"""
Return the cartesian components of the gradient
of a scalar field on the surface of the sphere.
The method consists of minimizing a quadratic functional Q(G) over
gradient vectors, where Q is an approxi... | python | {
"resource": ""
} |
q19689 | sTriangulation.tri_area | train | def tri_area(self, lons, lats):
"""
Calculate the area enclosed by 3 points on the unit sphere.
Parameters
----------
lons : array of floats, shape (3)
longitudinal coordinates in radians
lats : array of floats, shape (3)
latitudinal coordinates... | python | {
"resource": ""
} |
q19690 | sTriangulation.areas | train | def areas(self):
"""
Compute the area each triangle within the triangulation of points
on the unit sphere.
Returns
-------
area : array of floats, shape (nt,)
area of each triangle in self.simplices where nt
is the number of triangles.
N... | python | {
"resource": ""
} |
q19691 | sTriangulation.join | train | def join(self, t2, unique=False):
"""
Join this triangulation with another. If the points are known to have no duplicates, then
set unique=True to skip the testing and duplicate removal
"""
lonv1 = np.concatenate((self.lons, t2.lons), axis=0)
latv1 = np.concatenate((self... | python | {
"resource": ""
} |
q19692 | SalesforceBulk.get_query_batch_request | train | def get_query_batch_request(self, batch_id, job_id=None):
""" Fetch the request sent for the batch. Note should only used for query batches """
if not job_id:
job_id = self.lookup_job_id(batch_id)
url = self.endpoint + "/job/{}/batch/{}/request".format(job_id, batch_id)
resp... | python | {
"resource": ""
} |
q19693 | SalesforceBulk.abort_job | train | def abort_job(self, job_id):
"""Abort a given bulk job"""
doc = self.create_abort_job_doc()
url = self.endpoint + "/job/%s" % job_id
resp = requests.post(
url,
headers=self.headers(),
data=doc
)
self.check_status(resp) | python | {
"resource": ""
} |
q19694 | SalesforceBulk.get_all_results_for_query_batch | train | def get_all_results_for_query_batch(self, batch_id, job_id=None, chunk_size=2048):
"""
Gets result ids and generates each result set from the batch and returns it
as an generator fetching the next result set when needed
Args:
batch_id: id of batch
job_id: id of j... | python | {
"resource": ""
} |
q19695 | MatchApiV4.matchlist_by_account | train | def matchlist_by_account(
self,
region,
encrypted_account_id,
queue=None,
begin_time=None,
end_time=None,
begin_index=None,
end_index=None,
season=None,
champion=None,
):
"""
Get matchlist for ranked games played on give... | python | {
"resource": ""
} |
q19696 | MatchApiV4.timeline_by_match | train | def timeline_by_match(self, region, match_id):
"""
Get match timeline by match ID.
Not all matches have timeline data.
:param string region: The region to execute this request on
:param long match_id: The match ID.
:returns: MatchTimelineDto
"""
url, qu... | python | {
"resource": ""
} |
q19697 | RateLimitHandler.after_request | train | def after_request(self, region, endpoint_name, method_name, url, response):
"""
Called after a response is received and before it is returned to the user.
:param string region: the region of this request
:param string endpoint_name: the name of the endpoint that was requested
:p... | python | {
"resource": ""
} |
q19698 | LolStatusApiV3.shard_data | train | def shard_data(self, region):
"""
Get League of Legends status for the given shard.
Requests to this API are not counted against the application Rate Limits.
:param string region: the region to execute this request on
:returns: ShardStatus
"""
url, query = LolS... | python | {
"resource": ""
} |
q19699 | ChampionMasteryApiV4.by_summoner_by_champion | train | def by_summoner_by_champion(self, region, encrypted_summoner_id, champion_id):
"""
Get a champion mastery by player ID and champion ID.
:param string region: the region to execute this request on
:param string encrypted_summoner_id: Summoner ID associated wi... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.