_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q259000 | reapply_all | validation | def reapply_all(ast_node, lib2to3_node):
"""Reapplies the typed_ast node into the lib2to3 tree.
Also does post-processing. This is done in reverse order to enable placing
TypeVars and aliases that depend on one another.
"""
late_processing = reapply(ast_node, lib2to3_node)
for lazy_func in reve... | python | {
"resource": ""
} |
q259001 | fix_remaining_type_comments | validation | def fix_remaining_type_comments(node):
"""Converts type comments in `node` to proper annotated assignments."""
assert node.type == syms.file_input
last_n = None
for n in node.post_order():
if last_n is not None:
if n.type == token.NEWLINE and is_assignment(last_n):
f... | python | {
"resource": ""
} |
q259002 | parse_signature_type_comment | validation | def parse_signature_type_comment(type_comment):
"""Parse the fugly signature type comment into AST nodes.
Caveats: ASTifying **kwargs is impossible with the current grammar so we
hack it into unary subtraction (to differentiate from Starred in vararg).
For example from:
"(str, int, *int, **Any) ->... | python | {
"resource": ""
} |
q259003 | parse_type_comment | validation | def parse_type_comment(type_comment):
"""Parse a type comment string into AST nodes."""
try:
result = ast3.parse(type_comment, '<type_comment>', 'eval')
except SyntaxError:
raise ValueError(f"invalid type comment: {type_comment!r}") from None
assert isinstance(result, ast3.Expression)
... | python | {
"resource": ""
} |
q259004 | copy_arguments_to_annotations | validation | def copy_arguments_to_annotations(args, type_comment, *, is_method=False):
"""Copies AST nodes from `type_comment` into the ast3.arguments in `args`.
Does validaation of argument count (allowing for untyped self/cls)
and type (vararg and kwarg).
"""
if isinstance(type_comment, ast3.Ellipsis):
... | python | {
"resource": ""
} |
q259005 | copy_type_comments_to_annotations | validation | def copy_type_comments_to_annotations(args):
"""Copies argument type comments from the legacy long form to annotations
in the entire function signature.
"""
for arg in args.args:
copy_type_comment_to_annotation(arg)
if args.vararg:
copy_type_comment_to_annotation(args.vararg)
f... | python | {
"resource": ""
} |
q259006 | maybe_replace_any_if_equal | validation | def maybe_replace_any_if_equal(name, expected, actual):
"""Return the type given in `expected`.
Raise ValueError if `expected` isn't equal to `actual`. If --replace-any is
used, the Any type in `actual` is considered equal.
The implementation is naively checking if the string representation of
`a... | python | {
"resource": ""
} |
q259007 | remove_function_signature_type_comment | validation | def remove_function_signature_type_comment(body):
"""Removes the legacy signature type comment, leaving other comments if any."""
for node in body.children:
if node.type == token.INDENT:
prefix = node.prefix.lstrip()
if prefix.startswith('# type: '):
node.prefix =... | python | {
"resource": ""
} |
q259008 | get_offset_and_prefix | validation | def get_offset_and_prefix(body, skip_assignments=False):
"""Returns the offset after which a statement can be inserted to the `body`.
This offset is calculated to come after all imports, and maybe existing
(possibly annotated) assignments if `skip_assignments` is True.
Also returns the indentation pre... | python | {
"resource": ""
} |
q259009 | fix_line_numbers | validation | def fix_line_numbers(body):
r"""Recomputes all line numbers based on the number of \n characters."""
maxline = 0
for node in body.pre_order():
maxline += node.prefix.count('\n')
if isinstance(node, Leaf):
node.lineno = maxline
maxline += str(node.value).count('\n') | python | {
"resource": ""
} |
q259010 | new | validation | def new(n, prefix=None):
"""lib2to3's AST requires unique objects as children."""
if isinstance(n, Leaf):
return Leaf(n.type, n.value, prefix=n.prefix if prefix is None else prefix)
# this is hacky, we assume complex nodes are just being reused once from the
# original AST.
n.parent = None... | python | {
"resource": ""
} |
q259011 | S3._load_info | validation | def _load_info(self):
'''Get user info for GBDX S3, put into instance vars for convenience.
Args:
None.
Returns:
Dictionary with S3 access key, S3 secret key, S3 session token,
user bucket and user prefix (dict).
'''
url = '%s/prefix?duratio... | python | {
"resource": ""
} |
q259012 | PlotMixin.histogram_equalize | validation | def histogram_equalize(self, use_bands, **kwargs):
''' Equalize and the histogram and normalize value range
Equalization is on all three bands, not per-band'''
data = self._read(self[use_bands,...], **kwargs)
data = np.rollaxis(data.astype(np.float32), 0, 3)
flattened = data.... | python | {
"resource": ""
} |
q259013 | PlotMixin.histogram_match | validation | def histogram_match(self, use_bands, blm_source=None, **kwargs):
''' Match the histogram to existing imagery '''
assert has_rio, "To match image histograms please install rio_hist"
data = self._read(self[use_bands,...], **kwargs)
data = np.rollaxis(data.astype(np.float32), 0, 3)
... | python | {
"resource": ""
} |
q259014 | PlotMixin.histogram_stretch | validation | def histogram_stretch(self, use_bands, **kwargs):
''' entry point for contrast stretching '''
data = self._read(self[use_bands,...], **kwargs)
data = np.rollaxis(data.astype(np.float32), 0, 3)
return self._histogram_stretch(data, **kwargs) | python | {
"resource": ""
} |
q259015 | PlotMixin.ndvi | validation | def ndvi(self, **kwargs):
"""
Calculates Normalized Difference Vegetation Index using NIR and Red of an image.
Returns: numpy array with ndvi values
"""
data = self._read(self[self._ndvi_bands,...]).astype(np.float32)
return (data[0,:,:] - data[1,:,:]) / (data[0,:,:] + d... | python | {
"resource": ""
} |
q259016 | PlotMixin.ndwi | validation | def ndwi(self):
"""
Calculates Normalized Difference Water Index using Coastal and NIR2 bands for WV02, WV03.
For Landsat8 and sentinel2 calculated by using Green and NIR bands.
Returns: numpy array of ndwi values
"""
data = self._read(self[self._ndwi_bands,...]).astype(... | python | {
"resource": ""
} |
q259017 | PlotMixin.plot | validation | def plot(self, spec="rgb", **kwargs):
''' Plot the image with MatplotLib
Plot sizing includes default borders and spacing. If the image is shown in Jupyter the outside whitespace will be automatically cropped to save size, resulting in a smaller sized image than expected.
Histogram options:
... | python | {
"resource": ""
} |
q259018 | Idaho.describe_images | validation | def describe_images(self, idaho_image_results):
"""Describe the result set of a catalog search for IDAHO images.
Args:
idaho_image_results (dict): Result set of catalog search.
Returns:
results (json): The full catalog-search response for IDAHO images
... | python | {
"resource": ""
} |
q259019 | Idaho.get_chip | validation | def get_chip(self, coordinates, catid, chip_type='PAN', chip_format='TIF', filename='chip.tif'):
"""Downloads a native resolution, orthorectified chip in tif format
from a user-specified catalog id.
Args:
coordinates (list): Rectangle coordinates in order West, South, East, North.
... | python | {
"resource": ""
} |
q259020 | Idaho.create_leaflet_viewer | validation | def create_leaflet_viewer(self, idaho_image_results, filename):
"""Create a leaflet viewer html file for viewing idaho images.
Args:
idaho_image_results (dict): IDAHO image result set as returned from
the catalog.
filename (str): Where to ... | python | {
"resource": ""
} |
q259021 | is_ordered | validation | def is_ordered(cat_id):
"""
Checks to see if a CatalogID has been ordered or not.
Args:
catalogID (str): The catalog ID from the platform catalog.
Returns:
ordered (bool): Whether or not the image has been ordered
"""
url = 'https://rda.geobigdata.io/v1/stripMetadata/{}'.f... | python | {
"resource": ""
} |
q259022 | deprecate_module_attr | validation | def deprecate_module_attr(mod, deprecated):
"""Return a wrapped object that warns about deprecated accesses"""
deprecated = set(deprecated)
class Wrapper(object):
def __getattr__(self, attr):
if attr in deprecated:
warnings.warn("Property {} is deprecated".format(attr), G... | python | {
"resource": ""
} |
q259023 | PortList.get_matching_multiplex_port | validation | def get_matching_multiplex_port(self,name):
"""
Given a name, figure out if a multiplex port prefixes this name and return it. Otherwise return none.
"""
# short circuit: if the attribute name already exists return none
# if name in self._portnames: return None
# if no... | python | {
"resource": ""
} |
q259024 | Task.set | validation | def set(self, **kwargs):
"""
Set input values on task
Args:
arbitrary_keys: values for the keys
Returns:
None
"""
for port_name, port_value in kwargs.items():
# Support both port and port.value
if hasattr(port_value, 'v... | python | {
"resource": ""
} |
q259025 | Workflow.savedata | validation | def savedata(self, output, location=None):
'''
Save output data from any task in this workflow to S3
Args:
output: Reference task output (e.g. task.outputs.output1).
location (optional): Subfolder under which the output will be saved.
... | python | {
"resource": ""
} |
q259026 | Workflow.generate_workflow_description | validation | def generate_workflow_description(self):
'''
Generate workflow json for launching the workflow against the gbdx api
Args:
None
Returns:
json string
'''
if not self.tasks:
raise WorkflowError('Workflow contains no tasks, and cannot be ... | python | {
"resource": ""
} |
q259027 | Workflow.execute | validation | def execute(self):
'''
Execute the workflow.
Args:
None
Returns:
Workflow_id
'''
# if not self.tasks:
# raise WorkflowError('Workflow contains no tasks, and cannot be executed.')
# for task in self.tasks:
# self.d... | python | {
"resource": ""
} |
q259028 | Workflow.task_ids | validation | def task_ids(self):
'''
Get the task IDs of a running workflow
Args:
None
Returns:
List of task IDs
'''
if not self.id:
raise WorkflowError('Workflow is not running. Cannot get task IDs.')
if self.batch_values:
r... | python | {
"resource": ""
} |
q259029 | Workflow.cancel | validation | def cancel(self):
'''
Cancel a running workflow.
Args:
None
Returns:
None
'''
if not self.id:
raise WorkflowError('Workflow is not running. Cannot cancel.')
if self.batch_values:
self.workflow.batch_workflow_canc... | python | {
"resource": ""
} |
q259030 | Workflow.stdout | validation | def stdout(self):
''' Get stdout from all the tasks of a workflow.
Returns:
(list): tasks with their stdout
Example:
>>> workflow.stdout
[
{
"id": "4488895771403082552",
"taskType": "AOP_Strip_P... | python | {
"resource": ""
} |
q259031 | Workflow.stderr | validation | def stderr(self):
'''Get stderr from all the tasks of a workflow.
Returns:
(list): tasks with their stderr
Example:
>>> workflow.stderr
[
{
"id": "4488895771403082552",
"taskType": "AOP_Strip_Processor"... | python | {
"resource": ""
} |
q259032 | VectorLayer.layers | validation | def layers(self):
""" Renders the list of layers to add to the map.
Returns:
layers (list): list of layer entries suitable for use in mapbox-gl 'map.addLayer()' call
"""
layers = [self._layer_def(style) for style in self.styles]
return layers | python | {
"resource": ""
} |
q259033 | get_proj | validation | def get_proj(prj_code):
"""
Helper method for handling projection codes that are unknown to pyproj
Args:
prj_code (str): an epsg proj code
Returns:
projection: a pyproj projection
"""
if prj_code in CUSTOM_PRJ:
proj = pyproj.Proj(CUSTOM_PRJ[prj_code])
else... | python | {
"resource": ""
} |
q259034 | preview | validation | def preview(image, **kwargs):
''' Show a slippy map preview of the image. Requires iPython.
Args:
image (image): image object to display
zoom (int): zoom level to intialize the map, default is 16
center (list): center coordinates to initialize the map, defaults to center of image
... | python | {
"resource": ""
} |
q259035 | TaskRegistry.list | validation | def list(self):
"""Lists available and visible GBDX tasks.
Returns:
List of tasks
"""
r = self.gbdx_connection.get(self._base_url)
raise_for_status(r)
return r.json()['tasks'] | python | {
"resource": ""
} |
q259036 | TaskRegistry.register | validation | def register(self, task_json=None, json_filename=None):
"""Registers a new GBDX task.
Args:
task_json (dict): Dictionary representing task definition.
json_filename (str): A full path of a file with json representing the task definition.
Only one out of task_json and... | python | {
"resource": ""
} |
q259037 | TaskRegistry.get_definition | validation | def get_definition(self, task_name):
"""Gets definition of a registered GBDX task.
Args:
task_name (str): Task name.
Returns:
Dictionary representing the task definition.
"""
r = self.gbdx_connection.get(self._base_url + '/' + task_name)
raise_fo... | python | {
"resource": ""
} |
q259038 | TaskRegistry.delete | validation | def delete(self, task_name):
"""Deletes a GBDX task.
Args:
task_name (str): Task name.
Returns:
Response (str).
"""
r = self.gbdx_connection.delete(self._base_url + '/' + task_name)
raise_for_status(r)
return r.text | python | {
"resource": ""
} |
q259039 | TaskRegistry.update | validation | def update(self, task_name, task_json):
"""Updates a GBDX task.
Args:
task_name (str): Task name.
task_json (dict): Dictionary representing updated task definition.
Returns:
Dictionary representing the updated task definition.
"""
r = self.gb... | python | {
"resource": ""
} |
q259040 | to_geotiff | validation | def to_geotiff(arr, path='./output.tif', proj=None, spec=None, bands=None, **kwargs):
''' Write out a geotiff file of the image
Args:
path (str): path to write the geotiff file to, default is ./output.tif
proj (str): EPSG string of projection to reproject to
spec (str): if set to 'rgb',... | python | {
"resource": ""
} |
q259041 | Recipe.ingest_vectors | validation | def ingest_vectors(self, output_port_value):
''' append two required tasks to the given output to ingest to VS
'''
# append two tasks to self['definition']['tasks']
ingest_task = Task('IngestItemJsonToVectorServices')
ingest_task.inputs.items = output_port_value
ingest_ta... | python | {
"resource": ""
} |
q259042 | Recipe.get | validation | def get(self, recipe_id):
'''
Retrieves an AnswerFactory Recipe by id
Args:
recipe_id The id of the recipe
Returns:
A JSON representation of the recipe
'''
self.logger.debug('Retrieving recipe by id: ' + recipe_id)
url = '%(base_url)s/rec... | python | {
"resource": ""
} |
q259043 | Recipe.save | validation | def save(self, recipe):
'''
Saves an AnswerFactory Recipe
Args:
recipe (dict): Dictionary specifying a recipe
Returns:
AnswerFactory Recipe id
'''
# test if this is a create vs. an update
if 'id' in recipe and recipe['id'] is not None:
... | python | {
"resource": ""
} |
q259044 | Project.save | validation | def save(self, project):
'''
Saves an AnswerFactory Project
Args:
project (dict): Dictionary specifying an AnswerFactory Project.
Returns:
AnswerFactory Project id
'''
# test if this is a create vs. an update
if 'id' in project and proje... | python | {
"resource": ""
} |
q259045 | Project.delete | validation | def delete(self, project_id):
'''
Deletes a project by id
Args:
project_id: The project id to delete
Returns:
Nothing
'''
self.logger.debug('Deleting project by id: ' + project_id)
url = '%(base_url)s/%(project_id)s' % {
'ba... | python | {
"resource": ""
} |
q259046 | LineStyle.paint | validation | def paint(self):
"""
Renders a javascript snippet suitable for use as a mapbox-gl line paint entry
Returns:
A dict that can be converted to a mapbox-gl javascript paint snippet
"""
# TODO Figure out why i cant use some of these props
snippet = {
'... | python | {
"resource": ""
} |
q259047 | FillStyle.paint | validation | def paint(self):
"""
Renders a javascript snippet suitable for use as a mapbox-gl fill paint entry
Returns:
A dict that can be converted to a mapbox-gl javascript paint snippet
"""
snippet = {
'fill-opacity': VectorStyle.get_style_value(self.opacity),
... | python | {
"resource": ""
} |
q259048 | FillExtrusionStyle.paint | validation | def paint(self):
"""
Renders a javascript snippet suitable for use as a mapbox-gl fill-extrusion paint entry
Returns:
A dict that can be converted to a mapbox-gl javascript paint snippet
"""
snippet = {
'fill-extrusion-opacity': VectorStyle.get_style_valu... | python | {
"resource": ""
} |
q259049 | HeatmapStyle.paint | validation | def paint(self):
"""
Renders a javascript snippet suitable for use as a mapbox-gl heatmap paint entry
Returns:
A dict that can be converted to a mapbox-gl javascript paint snippet
"""
snippet = {
'heatmap-radius': VectorStyle.get_style_value(self.radius),... | python | {
"resource": ""
} |
q259050 | Vectors.create | validation | def create(self,vectors):
""" Create a vectors in the vector service.
Args:
vectors: A single geojson vector or a list of geojson vectors. Item_type and ingest_source are required.
Returns:
(list): IDs of the vectors created
Example:
>>> vectors.cre... | python | {
"resource": ""
} |
q259051 | Vectors.create_from_wkt | validation | def create_from_wkt(self, wkt, item_type, ingest_source, **attributes):
'''
Create a single vector in the vector service
Args:
wkt (str): wkt representation of the geometry
item_type (str): item_type of the vector
ingest_source (str): source of the vector
... | python | {
"resource": ""
} |
q259052 | Vectors.get | validation | def get(self, ID, index='vector-web-s'):
'''Retrieves a vector. Not usually necessary because searching is the best way to find & get stuff.
Args:
ID (str): ID of the vector object
index (str): Optional. Index the object lives in. defaults to 'vector-web-s'
Returns:
... | python | {
"resource": ""
} |
q259053 | Vectors.aggregate_query | validation | def aggregate_query(self, searchAreaWkt, agg_def, query=None, start_date=None, end_date=None, count=10, index=default_index):
"""Aggregates results of a query into buckets defined by the 'agg_def' parameter. The aggregations are
represented by dicts containing a 'name' key and a 'terms' key holding a l... | python | {
"resource": ""
} |
q259054 | Vectors.tilemap | validation | def tilemap(self, query, styles={}, bbox=[-180,-90,180,90], zoom=16,
api_key=os.environ.get('MAPBOX_API_KEY', None),
image=None, image_bounds=None,
index="vector-user-provided", name="GBDX_Task_Output", **kwargs):
"""
Renders a mapbox... | python | {
"resource": ""
} |
q259055 | Vectors.map | validation | def map(self, features=None, query=None, styles=None,
bbox=[-180,-90,180,90], zoom=10, center=None,
image=None, image_bounds=None, cmap='viridis',
api_key=os.environ.get('MAPBOX_API_KEY', None), **kwargs):
"""
Renders a mapbox gl map from a vector... | python | {
"resource": ""
} |
q259056 | DaskImage.read | validation | def read(self, bands=None, **kwargs):
"""Reads data from a dask array and returns the computed ndarray matching the given bands
Args:
bands (list): band indices to read from the image. Returns bands in the order specified in the list of bands.
Returns:
ndarray: a numpy ... | python | {
"resource": ""
} |
q259057 | DaskImage.randwindow | validation | def randwindow(self, window_shape):
"""Get a random window of a given shape from within an image
Args:
window_shape (tuple): The desired shape of the returned image as (height, width) in pixels.
Returns:
image: a new image object of the specified shape and same type
... | python | {
"resource": ""
} |
q259058 | DaskImage.iterwindows | validation | def iterwindows(self, count=64, window_shape=(256, 256)):
""" Iterate over random windows of an image
Args:
count (int): the number of the windows to generate. Defaults to 64, if `None` will continue to iterate over random windows until stopped.
window_shape (tuple): The desired... | python | {
"resource": ""
} |
q259059 | DaskImage.window_at | validation | def window_at(self, geom, window_shape):
"""Return a subsetted window of a given size, centered on a geometry object
Useful for generating training sets from vector training data
Will throw a ValueError if the window is not within the image bounds
Args:
geom (shapely,geomet... | python | {
"resource": ""
} |
q259060 | DaskImage.window_cover | validation | def window_cover(self, window_shape, pad=True):
""" Iterate over a grid of windows of a specified shape covering an image.
The image is divided into a grid of tiles of size window_shape. Each iteration returns
the next window.
Args:
window_shape (tuple): The desired shape ... | python | {
"resource": ""
} |
q259061 | GeoDaskImage.aoi | validation | def aoi(self, **kwargs):
""" Subsets the Image by the given bounds
Args:
bbox (list): optional. A bounding box array [minx, miny, maxx, maxy]
wkt (str): optional. A WKT geometry string
geojson (str): optional. A GeoJSON geometry dictionary
Returns:
... | python | {
"resource": ""
} |
q259062 | GeoDaskImage.pxbounds | validation | def pxbounds(self, geom, clip=False):
""" Returns the bounds of a geometry object in pixel coordinates
Args:
geom: Shapely geometry object or GeoJSON as Python dictionary or WKT string
clip (bool): Clip the bounds to the min/max extent of the image
Returns:
... | python | {
"resource": ""
} |
q259063 | GeoDaskImage.geotiff | validation | def geotiff(self, **kwargs):
""" Creates a geotiff on the filesystem
Args:
path (str): optional, path to write the geotiff file to, default is ./output.tif
proj (str): optional, EPSG string of projection to reproject to
spec (str): optional, if set to 'rgb', write ou... | python | {
"resource": ""
} |
q259064 | GeoDaskImage._parse_geoms | validation | def _parse_geoms(self, **kwargs):
""" Finds supported geometry types, parses them and returns the bbox """
bbox = kwargs.get('bbox', None)
wkt_geom = kwargs.get('wkt', None)
geojson = kwargs.get('geojson', None)
if bbox is not None:
g = box(*bbox)
elif wkt_geo... | python | {
"resource": ""
} |
q259065 | TmsMeta._tile_coords | validation | def _tile_coords(self, bounds):
""" convert mercator bbox to tile index limits """
tfm = partial(pyproj.transform,
pyproj.Proj(init="epsg:3857"),
pyproj.Proj(init="epsg:4326"))
bounds = ops.transform(tfm, box(*bounds)).bounds
# because tiles h... | python | {
"resource": ""
} |
q259066 | Workflow.launch | validation | def launch(self, workflow):
"""Launches GBDX workflow.
Args:
workflow (dict): Dictionary specifying workflow tasks.
Returns:
Workflow id (str).
"""
# hit workflow api
try:
r = self.gbdx_connection.post(self.workflows_url, json=workfl... | python | {
"resource": ""
} |
q259067 | Workflow.status | validation | def status(self, workflow_id):
"""Checks workflow status.
Args:
workflow_id (str): Workflow id.
Returns:
Workflow status (str).
"""
self.logger.debug('Get status of workflow: ' + workflow_id)
url = '%(wf_url)s/%(wf_id)s' % {
'wf_u... | python | {
"resource": ""
} |
q259068 | Workflow.get_stdout | validation | def get_stdout(self, workflow_id, task_id):
"""Get stdout for a particular task.
Args:
workflow_id (str): Workflow id.
task_id (str): Task id.
Returns:
Stdout of the task (string).
"""
url = '%(wf_url)s/%(wf_id)s/tasks/%(task_id)s/stdout... | python | {
"resource": ""
} |
q259069 | Workflow.cancel | validation | def cancel(self, workflow_id):
"""Cancels a running workflow.
Args:
workflow_id (str): Workflow id.
Returns:
Nothing
"""
self.logger.debug('Canceling workflow: ' + workflow_id)
url = '%(wf_url)s/%(wf_id)s/cancel' % {
'wf_u... | python | {
"resource": ""
} |
q259070 | Workflow.launch_batch_workflow | validation | def launch_batch_workflow(self, batch_workflow):
"""Launches GBDX batch workflow.
Args:
batch_workflow (dict): Dictionary specifying batch workflow tasks.
Returns:
Batch Workflow id (str).
"""
# hit workflow api
url = '%(base_url)s/batch_workflo... | python | {
"resource": ""
} |
q259071 | Workflow.batch_workflow_status | validation | def batch_workflow_status(self, batch_workflow_id):
"""Checks GBDX batch workflow status.
Args:
batch workflow_id (str): Batch workflow id.
Returns:
Batch Workflow status (str).
"""
self.logger.debug('Get status of batch workflow: ' + batch_workflow_... | python | {
"resource": ""
} |
q259072 | Ordering.order | validation | def order(self, image_catalog_ids, batch_size=100, callback=None):
'''Orders images from GBDX.
Args:
image_catalog_ids (str or list): A single catalog id or a list of
catalog ids.
batch_size (int): The image_catalog_ids w... | python | {
"resource": ""
} |
q259073 | Ordering.status | validation | def status(self, order_id):
'''Checks imagery order status. There can be more than one image per
order and this function returns the status of all images
within the order.
Args:
order_id (str): The id of the order placed.
Returns:
List ... | python | {
"resource": ""
} |
q259074 | Ordering.heartbeat | validation | def heartbeat(self):
'''
Check the heartbeat of the ordering API
Args: None
Returns: True or False
'''
url = '%s/heartbeat' % self.base_url
# Auth is not required to hit the heartbeat
r = requests.get(url)
try:
return r.json() == "... | python | {
"resource": ""
} |
q259075 | Catalog.get | validation | def get(self, catID, includeRelationships=False):
'''Retrieves the strip footprint WKT string given a cat ID.
Args:
catID (str): The source catalog ID from the platform catalog.
includeRelationships (bool): whether to include graph links to related objects. Default False.
... | python | {
"resource": ""
} |
q259076 | Catalog.get_strip_metadata | validation | def get_strip_metadata(self, catID):
'''Retrieves the strip catalog metadata given a cat ID.
Args:
catID (str): The source catalog ID from the platform catalog.
Returns:
metadata (dict): A metadata dictionary .
TODO: have this return a class object with int... | python | {
"resource": ""
} |
q259077 | Catalog.get_address_coords | validation | def get_address_coords(self, address):
''' Use the google geocoder to get latitude and longitude for an address string
Args:
address: any address string
Returns:
A tuple of (lat,lng)
'''
url = "https://maps.googleapis.com/maps/api/geocode/json?&address="... | python | {
"resource": ""
} |
q259078 | Catalog.search_address | validation | def search_address(self, address, filters=None, startDate=None, endDate=None, types=None):
''' Perform a catalog search over an address string
Args:
address: any address string
filters: Array of filters. Optional. Example:
[
"(sensorPlatformName = '... | python | {
"resource": ""
} |
q259079 | Catalog.search_point | validation | def search_point(self, lat, lng, filters=None, startDate=None, endDate=None, types=None, type=None):
''' Perform a catalog search over a specific point, specified by lat,lng
Args:
lat: latitude
lng: longitude
filters: Array of filters. Optional. Example:
... | python | {
"resource": ""
} |
q259080 | Catalog.get_data_location | validation | def get_data_location(self, catalog_id):
"""
Find and return the S3 data location given a catalog_id.
Args:
catalog_id: The catalog ID
Returns:
A string containing the s3 location of the data associated with a catalog ID. Returns
None if the catalog... | python | {
"resource": ""
} |
q259081 | Catalog.search | validation | def search(self, searchAreaWkt=None, filters=None, startDate=None, endDate=None, types=None):
''' Perform a catalog search
Args:
searchAreaWkt: WKT Polygon of area to search. Optional.
filters: Array of filters. Optional. Example:
[
"(sensorPlatfor... | python | {
"resource": ""
} |
q259082 | Catalog.get_most_recent_images | validation | def get_most_recent_images(self, results, types=[], sensors=[], N=1):
''' Return the most recent image
Args:
results: a catalog resultset, as returned from a search
types: array of types you want. optional.
sensors: array of sensornames. optional.
N: numb... | python | {
"resource": ""
} |
q259083 | BaseView.use | validation | def use(cls, name, method: [str, Set, List], url=None):
""" interface helper function"""
if not isinstance(method, (str, list, set, tuple)):
raise BaseException('Invalid type of method: %s' % type(method).__name__)
if isinstance(method, str):
method = {method}
#... | python | {
"resource": ""
} |
q259084 | validate | validation | def validate(method):
"""
Config option name value validator decorator.
"""
# Name error template
name_error = 'configuration option "{}" is not supported'
@functools.wraps(method)
def validator(self, name, *args):
if name not in self.allowed_opts:
raise ValueError(name_... | python | {
"resource": ""
} |
q259085 | Runner.run | validation | def run(self, ctx):
"""
Runs the current phase.
"""
# Reverse engine assertion if needed
if ctx.reverse:
self.engine.reverse()
if self.engine.empty:
raise AssertionError('grappa: no assertions to run')
try:
# Run assertion in ... | python | {
"resource": ""
} |
q259086 | Operator.run_matcher | validation | def run_matcher(self, subject, *expected, **kw):
"""
Runs the operator matcher test function.
"""
# Update assertion expectation
self.expected = expected
_args = (subject,)
if self.kind == OperatorTypes.MATCHER:
_args += expected
try:
... | python | {
"resource": ""
} |
q259087 | Operator.run | validation | def run(self, *args, **kw):
"""
Runs the current operator with the subject arguments to test.
This method is implemented by matchers only.
"""
log.debug('[operator] run "{}" with arguments: {}'.format(
self.__class__.__name__, args
))
if self.kind ==... | python | {
"resource": ""
} |
q259088 | operator | validation | def operator(name=None, operators=None, aliases=None, kind=None):
"""
Registers a new operator function in the test engine.
Arguments:
*args: variadic arguments.
**kw: variadic keyword arguments.
Returns:
function
"""
def delegator(assertion, subject, expected, *args, *... | python | {
"resource": ""
} |
q259089 | attribute | validation | def attribute(*args, **kw):
"""
Registers a new attribute only operator function in the test engine.
Arguments:
*args: variadic arguments.
**kw: variadic keyword arguments.
Returns:
function
"""
return operator(kind=Operator.Type.ATTRIBUTE, *args, **kw) | python | {
"resource": ""
} |
q259090 | use | validation | def use(plugin):
"""
Register plugin in grappa.
`plugin` argument can be a function or a object that implement `register`
method, which should accept one argument: `grappa.Engine` instance.
Arguments:
plugin (function|module): grappa plugin object to register.
Raises:
ValueErr... | python | {
"resource": ""
} |
q259091 | load | validation | def load():
"""
Loads the built-in operators into the global test engine.
"""
for operator in operators:
module, symbols = operator[0], operator[1:]
path = 'grappa.operators.{}'.format(module)
# Dynamically import modules
operator = __import__(path, None, None, symbols)
... | python | {
"resource": ""
} |
q259092 | register_operators | validation | def register_operators(*operators):
"""
Registers one or multiple operators in the test engine.
"""
def validate(operator):
if isoperator(operator):
return True
raise NotImplementedError('invalid operator: {}'.format(operator))
def register(operator):
# Register... | python | {
"resource": ""
} |
q259093 | OMXPlayer.set_rate | validation | def set_rate(self, rate):
"""
Set the playback rate of the video as a multiple of the default playback speed
Examples:
>>> player.set_rate(2)
# Will play twice as fast as normal speed
>>> player.set_rate(0.5)
# Will play half speed
"""
... | python | {
"resource": ""
} |
q259094 | OMXPlayer.play_pause | validation | def play_pause(self):
"""
Pause playback if currently playing, otherwise start playing if currently paused.
"""
self._player_interface.PlayPause()
self._is_playing = not self._is_playing
if self._is_playing:
self.playEvent(self)
else:
self.... | python | {
"resource": ""
} |
q259095 | OMXPlayer.seek | validation | def seek(self, relative_position):
"""
Seek the video by `relative_position` seconds
Args:
relative_position (float): The position in seconds to seek to.
"""
self._player_interface.Seek(Int64(1000.0 * 1000 * relative_position))
self.seekEvent(self, relative_p... | python | {
"resource": ""
} |
q259096 | OMXPlayer.set_position | validation | def set_position(self, position):
"""
Set the video to playback position to `position` seconds from the start of the video
Args:
position (float): The position in seconds.
"""
self._player_interface.SetPosition(ObjectPath("/not/used"), Int64(position * 1000.0 * 1000)... | python | {
"resource": ""
} |
q259097 | OMXPlayer.set_video_pos | validation | def set_video_pos(self, x1, y1, x2, y2):
"""
Set the video position on the screen
Args:
x1 (int): Top left x coordinate (px)
y1 (int): Top left y coordinate (px)
x2 (int): Bottom right x coordinate (px)
y2 (int): Bottom right y coordinate (px)
... | python | {
"resource": ""
} |
q259098 | OMXPlayer.play_sync | validation | def play_sync(self):
"""
Play the video and block whilst the video is playing
"""
self.play()
logger.info("Playing synchronously")
try:
time.sleep(0.05)
logger.debug("Wait for playing to start")
while self.is_playing():
... | python | {
"resource": ""
} |
q259099 | OMXPlayer.play | validation | def play(self):
"""
Play the video asynchronously returning control immediately to the calling code
"""
if not self.is_playing():
self.play_pause()
self._is_playing = True
self.playEvent(self) | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.