_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q243100 | BaseMetadata.set | train | def set(self, name, value, xml_path):
"""
Create a new metadata property.
The accepted type depends on the property type which is determined
by the xml_path
:param name: the name of the property
:type name: str
:param value: the value of the property
:ty... | python | {
"resource": ""
} |
q243101 | BaseMetadata.write_to_file | train | def write_to_file(self, destination_path):
"""
Writes the metadata json or xml to a file.
:param destination_path: the file path the file format is inferred
from the destination_path extension.
:type destination_path: str
:return: the written metadata
:rtype: str... | python | {
"resource": ""
} |
q243102 | BaseMetadata.get_writable_metadata | train | def get_writable_metadata(self, file_format):
"""
Convert the metadata to a writable form.
:param file_format: the needed format can be json or xml
:type file_format: str
:return: the dupled metadata
:rtype: str
"""
if file_format == 'json':
m... | python | {
"resource": ""
} |
q243103 | BaseMetadata.read_from_ancillary_file | train | def read_from_ancillary_file(self, custom_xml=None):
"""
try to read xml and json from existing files or db.
This is used when instantiating a new metadata object. We explicitly
check if a custom XML was passed so we give it priority on the JSON.
If no custom XML is passed, JSON... | python | {
"resource": ""
} |
q243104 | BaseMetadata.update_from_dict | train | def update_from_dict(self, keywords):
"""Set properties of metadata using key and value from keywords
:param keywords: A dictionary of keywords (key, value).
:type keywords: dict
"""
for key, value in list(keywords.items()):
setattr(self, key, value) | python | {
"resource": ""
} |
q243105 | MultiBufferDialog.accept | train | def accept(self):
"""Process the layer for multi buffering and generate a new layer.
.. note:: This is called on OK click.
"""
# set parameter from dialog
input_layer = self.layer.currentLayer()
output_path = self.output_form.text()
radius = self.get_classificati... | python | {
"resource": ""
} |
q243106 | MultiBufferDialog.on_directory_button_tool_clicked | train | def on_directory_button_tool_clicked(self):
"""Autoconnect slot activated when directory button is clicked."""
# noinspection PyCallByClass,PyTypeChecker
# set up parameter from dialog
input_path = self.layer.currentLayer().source()
input_directory, self.output_filename = os.path... | python | {
"resource": ""
} |
q243107 | MultiBufferDialog.get_output_from_input | train | def get_output_from_input(self):
"""Populate output form with default output path based on input layer.
"""
input_path = self.layer.currentLayer().source()
output_path = (
os.path.splitext(input_path)[0] + '_multi_buffer'
+ os.path.splitext(input_path)[1])
... | python | {
"resource": ""
} |
q243108 | MultiBufferDialog.populate_hazard_classification | train | def populate_hazard_classification(self):
"""Populate hazard classification on hazard class form."""
new_class = {
'value': self.radius_form.value(),
'name': self.class_form.text()}
self.classification.append(new_class)
self.classification = sorted(
se... | python | {
"resource": ""
} |
q243109 | MultiBufferDialog.remove_selected_classification | train | def remove_selected_classification(self):
"""Remove selected item on hazard class form."""
removed_classes = self.hazard_class_form.selectedItems()
current_item = self.hazard_class_form.currentItem()
removed_index = self.hazard_class_form.indexFromItem(current_item)
del self.clas... | python | {
"resource": ""
} |
q243110 | MultiBufferDialog.get_classification | train | def get_classification(self):
"""Get all hazard class created by user.
:return: Hazard class definition created by user.
:rtype: OrderedDict
"""
classification_dictionary = {}
for item in self.classification:
classification_dictionary[item['value']] = item['n... | python | {
"resource": ""
} |
q243111 | MultiBufferDialog.directory_button_status | train | def directory_button_status(self):
"""Function to enable or disable directory button."""
if self.layer.currentLayer():
self.directory_button.setEnabled(True)
else:
self.directory_button.setEnabled(False) | python | {
"resource": ""
} |
q243112 | MultiBufferDialog.add_class_button_status | train | def add_class_button_status(self):
"""Function to enable or disable add class button."""
if self.class_form.text() and self.radius_form.value() >= 0:
self.add_class_button.setEnabled(True)
else:
self.add_class_button.setEnabled(False) | python | {
"resource": ""
} |
q243113 | MultiBufferDialog.ok_button_status | train | def ok_button_status(self):
"""Function to enable or disable OK button."""
if not self.layer.currentLayer():
self.button_box.button(
QtWidgets.QDialogButtonBox.Ok).setEnabled(False)
elif (self.hazard_class_form.count() > 0
and self.layer.currentLayer().n... | python | {
"resource": ""
} |
q243114 | MultiBufferDialog.help_toggled | train | def help_toggled(self, flag):
"""Show or hide the help tab in the stacked widget.
:param flag: Flag indicating whether help should be shown or hidden.
:type flag: bool
"""
if flag:
self.help_button.setText(self.tr('Hide Help'))
self.show_help()
el... | python | {
"resource": ""
} |
q243115 | convert_mmi_data | train | def convert_mmi_data(
grid_xml_path,
title,
source,
output_path=None,
algorithm=None,
algorithm_filename_flag=True,
smoothing_method=NONE_SMOOTHING,
smooth_sigma=0.9,
extra_keywords=None
):
"""Convenience function to convert a single file.
... | python | {
"resource": ""
} |
q243116 | ShakeGrid.extract_date_time | train | def extract_date_time(self, the_time_stamp):
"""Extract the parts of a date given a timestamp as per below example.
:param the_time_stamp: The 'event_timestamp' attribute from grid.xml.
:type the_time_stamp: str
# now separate out its parts
# >>> e = "2012-08-07T01:55:12WIB"
... | python | {
"resource": ""
} |
q243117 | ShakeGrid.grid_file_path | train | def grid_file_path(self):
"""Validate that grid file path points to a file.
:return: The grid xml file path.
:rtype: str
:raises: GridXmlFileNotFoundError
"""
if os.path.isfile(self.grid_xml_path):
return self.grid_xml_path
else:
raise Gr... | python | {
"resource": ""
} |
q243118 | ShakeGrid.mmi_to_delimited_text | train | def mmi_to_delimited_text(self):
"""Return the mmi data as a delimited test string.
:returns: A delimited text string that can easily be written to disk
for e.g. use by gdal_grid.
:rtype: str
The returned string will look like this::
123.0750,01.7900,1
... | python | {
"resource": ""
} |
q243119 | ShakeGrid.mmi_to_delimited_file | train | def mmi_to_delimited_file(self, force_flag=True):
"""Save mmi_data to delimited text file suitable for gdal_grid.
The output file will be of the same format as strings returned from
:func:`mmi_to_delimited_text`.
:param force_flag: Whether to force the regeneration of the output
... | python | {
"resource": ""
} |
q243120 | ShakeGrid.mmi_to_vrt | train | def mmi_to_vrt(self, force_flag=True):
"""Save the mmi_data to an ogr vrt text file.
:param force_flag: Whether to force the regeneration of the output
file. Defaults to False.
:type force_flag: bool
:returns: The absolute file system path to the .vrt text file.
:rt... | python | {
"resource": ""
} |
q243121 | ShakeGrid._run_command | train | def _run_command(self, command):
"""Run a command and raise any error as needed.
This is a simple runner for executing gdal commands.
:param command: A command string to be run.
:type command: str
:raises: Any exceptions will be propagated.
"""
try:
... | python | {
"resource": ""
} |
q243122 | ShakeGrid.mmi_to_raster | train | def mmi_to_raster(self, force_flag=False, algorithm=USE_ASCII):
"""Convert the grid.xml's mmi column to a raster using gdal_grid.
A geotiff file will be created.
Unfortunately no python bindings exist for doing this so we are
going to do it using a shell call.
.. see also:: ht... | python | {
"resource": ""
} |
q243123 | ShakeGrid.mmi_to_shapefile | train | def mmi_to_shapefile(self, force_flag=False):
"""Convert grid.xml's mmi column to a vector shp file using ogr2ogr.
An ESRI shape file will be created.
:param force_flag: bool (Optional). Whether to force the regeneration
of the output file. Defaults to False.
:return: Path... | python | {
"resource": ""
} |
q243124 | ShakeGrid.create_keyword_file | train | def create_keyword_file(self, algorithm):
"""Create keyword file for the raster file created.
Basically copy a template from keyword file in converter data
and add extra keyword (usually a title)
:param algorithm: Which re-sampling algorithm to use.
valid options are 'neare... | python | {
"resource": ""
} |
q243125 | ShakeGrid.mmi_to_ascii | train | def mmi_to_ascii(self, force_flag=False):
"""Convert grid.xml mmi column to a ascii raster file."""
ascii_path = os.path.join(
self.output_dir, '%s.asc' % self.output_basename)
# Short circuit if the tif is already created.
if os.path.exists(ascii_path) and force_flag is not ... | python | {
"resource": ""
} |
q243126 | StepFcSummary.set_widgets | train | def set_widgets(self):
"""Set widgets on the Summary tab."""
if self.parent.aggregation_layer:
aggr = self.parent.aggregation_layer.name()
else:
aggr = self.tr('no aggregation')
html = self.tr('Please ensure the following information '
'is ... | python | {
"resource": ""
} |
q243127 | inasafe_analysis_summary_field_value | train | def inasafe_analysis_summary_field_value(field, feature, parent):
"""Retrieve a value from a field in the analysis summary layer.
e.g. inasafe_analysis_summary_field_value('total_not_exposed') -> 3
"""
_ = feature, parent # NOQA
project_context_scope = QgsExpressionContextUtils.projectScope(
... | python | {
"resource": ""
} |
q243128 | inasafe_sub_analysis_summary_field_value | train | def inasafe_sub_analysis_summary_field_value(
exposure_key, field, feature, parent):
"""Retrieve a value from field in the specified exposure analysis layer.
"""
_ = feature, parent # NOQA
project_context_scope = QgsExpressionContextUtils.projectScope(
QgsProject.instance())
projec... | python | {
"resource": ""
} |
q243129 | inasafe_exposure_summary_field_values | train | def inasafe_exposure_summary_field_values(field, feature, parent):
"""Retrieve all values from a field in the exposure summary layer.
"""
_ = feature, parent # NOQA
layer = exposure_summary_layer()
if not layer:
return None
index = layer.fields().lookupField(field)
if index < 0:
... | python | {
"resource": ""
} |
q243130 | inasafe_place_value_name | train | def inasafe_place_value_name(number, feature, parent):
"""Given a number, it will return the place value name.
For instance:
* inasafe_place_value_name(10) -> Ten \n
* inasafe_place_value_name(1700) -> Thousand
It needs to be used with inasafe_place_value_coefficient.
"""
_ = feature, pa... | python | {
"resource": ""
} |
q243131 | inasafe_place_value_coefficient | train | def inasafe_place_value_coefficient(number, feature, parent):
"""Given a number, it will return the coefficient of the place value name.
For instance:
* inasafe_place_value_coefficient(10) -> 1
* inasafe_place_value_coefficient(1700) -> 1.7
It needs to be used with inasafe_number_denomination_un... | python | {
"resource": ""
} |
q243132 | inasafe_place_value_percentage | train | def inasafe_place_value_percentage(number, total, feature, parent):
"""Given a number and total, it will return the percentage of the number
to the total.
For instance:
* inasafe_place_value_percentage(inasafe_analysis_summary_field_value(
'female_displaced'), inasafe_analysis_summary_field_v... | python | {
"resource": ""
} |
q243133 | beautify_date | train | def beautify_date(inasafe_time, feature, parent):
"""Given an InaSAFE analysis time, it will convert it to a date with
year-month-date format.
For instance:
* beautify_date( @start_datetime ) -> will convert datetime provided by
qgis_variable.
"""
_ = feature, parent # NOQA
datet... | python | {
"resource": ""
} |
q243134 | hazard_extra_keyword | train | def hazard_extra_keyword(keyword, feature, parent):
"""Given a keyword, it will return the value of the keyword
from the hazard layer's extra keywords.
For instance:
* hazard_extra_keyword( 'depth' ) -> will return the value of 'depth'
in current hazard layer's extra keywords.
"""
_ =... | python | {
"resource": ""
} |
q243135 | NumberedList.to_html | train | def to_html(self):
"""Render a Text MessageElement as html
Args:
None
Returns:
Str the html representation of the Text MessageElement
Raises:
Errors are propagated
"""
if self.items is None:
return
else:
... | python | {
"resource": ""
} |
q243136 | _check_value_mapping | train | def _check_value_mapping(layer, exposure_key=None):
"""Loop over the exposure type field and check if the value map is correct.
:param layer: The layer
:type layer: QgsVectorLayer
:param exposure_key: The exposure key.
:type exposure_key: str
"""
index = layer.fields().lookupField(exposure... | python | {
"resource": ""
} |
q243137 | clean_inasafe_fields | train | def clean_inasafe_fields(layer):
"""Clean inasafe_fields based on keywords.
1. Must use standard field names.
2. Sum up list of fields' value and put in the standard field name.
3. Remove un-used fields.
:param layer: The layer
:type layer: QgsVectorLayer
"""
fields = []
# Exposure... | python | {
"resource": ""
} |
q243138 | _size_is_needed | train | def _size_is_needed(layer):
"""Checker if we need the size field.
:param layer: The layer to test.
:type layer: QgsVectorLayer
:return: If we need the size field.
:rtype: bool
"""
exposure = layer.keywords.get('exposure')
if not exposure:
# The layer is not an exposure.
... | python | {
"resource": ""
} |
q243139 | _remove_features | train | def _remove_features(layer):
"""Remove features which do not have information for InaSAFE or an invalid
geometry.
:param layer: The vector layer.
:type layer: QgsVectorLayer
"""
# Get the layer purpose of the layer.
layer_purpose = layer.keywords['layer_purpose']
layer_subcategory = lay... | python | {
"resource": ""
} |
q243140 | _add_id_column | train | def _add_id_column(layer):
"""Add an ID column if it's not present in the attribute table.
:param layer: The vector layer.
:type layer: QgsVectorLayer
"""
layer_purpose = layer.keywords['layer_purpose']
mapping = {
layer_purpose_exposure['key']: exposure_id_field,
layer_purpose_... | python | {
"resource": ""
} |
q243141 | _add_default_exposure_class | train | def _add_default_exposure_class(layer):
"""The layer doesn't have an exposure class, we need to add it.
:param layer: The vector layer.
:type layer: QgsVectorLayer
"""
layer.startEditing()
field = create_field_from_definition(exposure_class_field)
layer.keywords['inasafe_fields'][exposure_... | python | {
"resource": ""
} |
q243142 | sum_fields | train | def sum_fields(layer, output_field_key, input_fields):
"""Sum the value of input_fields and put it as output_field.
:param layer: The vector layer.
:type layer: QgsVectorLayer
:param output_field_key: The output field definition key.
:type output_field_key: basestring
:param input_fields: Lis... | python | {
"resource": ""
} |
q243143 | get_needs_provenance | train | def get_needs_provenance(parameters):
"""Get the provenance of minimum needs.
:param parameters: A dictionary of impact function parameters.
:type parameters: dict
:returns: A parameter of provenance
:rtype: TextParameter
"""
if 'minimum needs' not in parameters:
return None
ne... | python | {
"resource": ""
} |
q243144 | NeedsProfile.load | train | def load(self):
"""Load the minimum needs.
If the minimum needs defined in QSettings use it, if not, get the
most relevant available minimum needs (based on QGIS locale). The
last thing to do is to just use the default minimum needs.
"""
self.minimum_needs = self.setting... | python | {
"resource": ""
} |
q243145 | NeedsProfile.load_profile | train | def load_profile(self, profile):
"""Load a specific profile into the current minimum needs.
:param profile: The profile's name
:type profile: basestring, str
"""
profile_path = os.path.join(
self.root_directory, 'minimum_needs', profile + '.json')
self.read_f... | python | {
"resource": ""
} |
q243146 | NeedsProfile.save_profile | train | def save_profile(self, profile):
"""Save the current minimum needs into a new profile.
:param profile: The profile's name
:type profile: basestring, str
"""
profile = profile.replace('.json', '')
profile_path = os.path.join(
self.root_directory,
'... | python | {
"resource": ""
} |
q243147 | NeedsProfile.get_profiles | train | def get_profiles(self, overwrite=False):
"""Get all the minimum needs profiles.
:returns: The minimum needs by name.
:rtype: list
"""
def sort_by_locale(unsorted_profiles, locale):
"""Sort the profiles by language settings.
The profiles that are in the s... | python | {
"resource": ""
} |
q243148 | NeedsProfile.get_needs_parameters | train | def get_needs_parameters(self):
"""Get the minimum needs resources in parameter format
:returns: The minimum needs resources wrapped in parameters.
:rtype: list
"""
parameters = []
for resource in self.minimum_needs['resources']:
parameter = ResourceParameter... | python | {
"resource": ""
} |
q243149 | NeedsProfile.format_sentence | train | def format_sentence(sentence, resource):
"""Populate the placeholders in the sentence.
:param sentence: The sentence with placeholder keywords.
:type sentence: basestring, str
:param resource: The resource to be placed into the sentence.
:type resource: dict
:returns: ... | python | {
"resource": ""
} |
q243150 | NeedsProfile.remove_profile | train | def remove_profile(self, profile):
"""Remove a profile.
:param profile: The profile to be removed.
:type profile: basestring, str
"""
self.remove_file(
os.path.join(
self.root_directory, 'minimum_needs', profile + '.json')
) | python | {
"resource": ""
} |
q243151 | tr | train | def tr(text, context='@default'):
"""We define a tr function alias here since the utilities implementation
below is not a class and does not inherit from QObject.
.. note:: see http://tinyurl.com/pyqt-differences
:param text: String to be translated
:type text: str, unicode
:param context: A ... | python | {
"resource": ""
} |
q243152 | locale | train | def locale(qsetting=''):
"""Get the name of the currently active locale.
:param qsetting: String to specify the QSettings. By default,
use empty string.
:type qsetting: str
:returns: Name of the locale e.g. 'id'
:rtype: str
"""
override_flag = QSettings(qsetting).value(
'lo... | python | {
"resource": ""
} |
q243153 | StepKwBandSelector.update_band_description | train | def update_band_description(self):
"""Helper to update band description."""
self.clear_further_steps()
# Set widgets
selected_band = self.selected_band()
statistics = self.parent.layer.dataProvider().bandStatistics(
selected_band,
QgsRasterBandStats.All,
... | python | {
"resource": ""
} |
q243154 | StepKwBandSelector.selected_band | train | def selected_band(self):
"""Obtain the layer mode selected by user.
:returns: selected layer mode.
:rtype: string, None
"""
item = self.lstBands.currentItem()
return item.data(QtCore.Qt.UserRole) | python | {
"resource": ""
} |
q243155 | merge_dictionaries | train | def merge_dictionaries(base_dict, extra_dict):
"""
merge two dictionaries.
if both have a same key, the one from extra_dict is taken
:param base_dict: first dictionary
:type base_dict: dict
:param extra_dict: second dictionary
:type extra_dict: dict
:return: a merge of the two dictiona... | python | {
"resource": ""
} |
q243156 | read_property_from_xml | train | def read_property_from_xml(root, path):
"""
Get the text from an XML property.
Whitespaces, tabs and new lines are trimmed
:param root: container in which we search
:type root: ElementTree.Element
:param path: path to search in root
:type path: str
:return: the text of the element at t... | python | {
"resource": ""
} |
q243157 | InaSAFEReportContext.north_arrow | train | def north_arrow(self, north_arrow_path):
"""Set image that will be used as north arrow in reports.
:param north_arrow_path: Path to the north arrow image.
:type north_arrow_path: str
"""
if isinstance(north_arrow_path, str) and os.path.exists(
north_arrow_path):
... | python | {
"resource": ""
} |
q243158 | InaSAFEReportContext.organisation_logo | train | def organisation_logo(self, logo):
"""Set image that will be used as organisation logo in reports.
:param logo: Path to the organisation logo image.
:type logo: str
"""
if isinstance(logo, str) and os.path.exists(logo):
self._organisation_logo = logo
else:
... | python | {
"resource": ""
} |
q243159 | InaSAFEReportContext.disclaimer | train | def disclaimer(self, text):
"""Set text that will be used as disclaimer in reports.
:param text: Disclaimer text
:type text: str
"""
if not isinstance(text, str):
self._disclaimer = disclaimer()
else:
self._disclaimer = text | python | {
"resource": ""
} |
q243160 | ImpactReport.output_folder | train | def output_folder(self, value):
"""Output folder path for the rendering.
:param value: output folder path
:type value: str
"""
self._output_folder = value
if not os.path.exists(self._output_folder):
os.makedirs(self._output_folder) | python | {
"resource": ""
} |
q243161 | ImpactReport._check_layer_count | train | def _check_layer_count(self, layer):
"""Check for the validity of the layer.
:param layer: QGIS layer
:type layer: qgis.core.QgsVectorLayer
:return:
"""
if layer:
if not layer.isValid():
raise ImpactReport.LayerException('Layer is not valid')
... | python | {
"resource": ""
} |
q243162 | ImpactReport.map_title | train | def map_title(self):
"""Get the map title from the layer keywords if possible.
:returns: None on error, otherwise the title.
:rtype: None, str
"""
# noinspection PyBroadException
try:
title = self._keyword_io.read_keywords(
self.impact, 'map_t... | python | {
"resource": ""
} |
q243163 | ImpactReport.map_legend_attributes | train | def map_legend_attributes(self):
"""Get the map legend attribute from the layer keywords if possible.
:returns: None on error, otherwise the attributes (notes and units).
:rtype: None, str
"""
LOGGER.debug('InaSAFE Map getMapLegendAttributes called')
legend_attribute_lis... | python | {
"resource": ""
} |
q243164 | GeoPackage._vector_layers | train | def _vector_layers(self):
"""Return a list of vector layers available.
:return: List of vector layers available in the geopackage.
:rtype: list
.. versionadded:: 4.0
"""
layers = []
vector_datasource = self.vector_driver.Open(
self.uri.absoluteFilePa... | python | {
"resource": ""
} |
q243165 | GeoPackage._raster_layers | train | def _raster_layers(self):
"""Return a list of raster layers available.
:return: List of raster layers available in the geopackage.
:rtype: list
.. versionadded:: 4.0
"""
layers = []
raster_datasource = gdal.Open(self.uri.absoluteFilePath())
if raster_da... | python | {
"resource": ""
} |
q243166 | GeoPackage._add_vector_layer | train | def _add_vector_layer(self, vector_layer, layer_name, save_style=False):
"""Add a vector layer to the geopackage.
:param vector_layer: The layer to add.
:type vector_layer: QgsVectorLayer
:param layer_name: The name of the layer in the datastore.
:type layer_name: str
... | python | {
"resource": ""
} |
q243167 | GeoPackage._add_tabular_layer | train | def _add_tabular_layer(self, tabular_layer, layer_name, save_style=False):
"""Add a tabular layer to the geopackage.
:param tabular_layer: The layer to add.
:type tabular_layer: QgsVectorLayer
:param layer_name: The name of the layer in the datastore.
:type layer_name: str
... | python | {
"resource": ""
} |
q243168 | StepFcHazLayerFromCanvas.selected_canvas_hazlayer | train | def selected_canvas_hazlayer(self):
"""Obtain the canvas layer selected by user.
:returns: The currently selected map layer in the list.
:rtype: QgsMapLayer
"""
if self.lstCanvasHazLayers.selectedItems():
item = self.lstCanvasHazLayers.currentItem()
else:
... | python | {
"resource": ""
} |
q243169 | StepFcHazLayerFromCanvas.list_compatible_canvas_layers | train | def list_compatible_canvas_layers(self):
"""Fill the list widget with compatible layers.
:returns: Metadata of found layers.
:rtype: list of dicts
"""
italic_font = QFont()
italic_font.setItalic(True)
list_widget = self.lstCanvasHazLayers
# Add compatible... | python | {
"resource": ""
} |
q243170 | StepFcHazLayerFromCanvas.set_widgets | train | def set_widgets(self):
"""Set widgets on the Hazard Layer From TOC tab."""
# The list is already populated in the previous step, but now we
# need to do it again in case we're back from the Keyword Wizard.
# First, preserve self.parent.layer before clearing the list
last_layer = ... | python | {
"resource": ""
} |
q243171 | ImpactFunction.performance_log_message | train | def performance_log_message(self):
"""Return the profiling log as a message."""
message = m.Message()
table = m.Table(style_class='table table-condensed table-striped')
row = m.Row()
row.add(m.Cell(tr('Function'), header=True))
row.add(m.Cell(tr('Time'), header=True))
... | python | {
"resource": ""
} |
q243172 | ImpactFunction.requested_extent | train | def requested_extent(self, extent):
"""Setter for extent property.
:param extent: Analysis boundaries expressed as a QgsRectangle.
The extent CRS should match the crs property of this IF
instance.
:type extent: QgsRectangle
"""
if isinstance(extent, QgsRe... | python | {
"resource": ""
} |
q243173 | ImpactFunction.crs | train | def crs(self, crs):
"""Setter for extent_crs property.
:param crs: The coordinate reference system for the analysis boundary.
:type crs: QgsCoordinateReferenceSystem
"""
if isinstance(crs, QgsCoordinateReferenceSystem):
self._crs = crs
self._is_ready = Fa... | python | {
"resource": ""
} |
q243174 | ImpactFunction.datastore | train | def datastore(self, datastore):
"""Setter for the datastore.
:param datastore: The datastore.
:type datastore: DataStore
"""
if isinstance(datastore, DataStore):
self._datastore = datastore
else:
raise Exception('%s is not a valid datastore.' % da... | python | {
"resource": ""
} |
q243175 | ImpactFunction.duration | train | def duration(self):
"""The duration of running the impact function in seconds.
Return 0 if the start or end datetime is None.
:return: The duration.
:rtype: float
"""
if self.end_datetime is None or self.start_datetime is None:
return 0
return (self.... | python | {
"resource": ""
} |
q243176 | ImpactFunction.console_progress_callback | train | def console_progress_callback(current, maximum, message=None):
"""Simple console based callback implementation for tests.
:param current: Current progress.
:type current: int
:param maximum: Maximum range (point at which task is complete.
:type maximum: int
:param mess... | python | {
"resource": ""
} |
q243177 | ImpactFunction.set_state_process | train | def set_state_process(self, context, process):
"""Method to append process for a context in the IF state.
:param context: It can be a layer purpose or a section (impact
function, post processor).
:type context: str, unicode
:param process: A text explain the process.
... | python | {
"resource": ""
} |
q243178 | ImpactFunction.set_state_info | train | def set_state_info(self, context, key, value):
"""Method to add information for a context in the IF state.
:param context: It can be a layer purpose or a section (impact
function, post processor).
:type context: str, unicode
:param key: A key for the information, e.g. algor... | python | {
"resource": ""
} |
q243179 | ImpactFunction.debug_layer | train | def debug_layer(self, layer, check_fields=True, add_to_datastore=None):
"""Write the layer produced to the datastore if debug mode is on.
:param layer: The QGIS layer to check and save.
:type layer: QgsMapLayer
:param check_fields: Boolean to check or not inasafe_fields.
By... | python | {
"resource": ""
} |
q243180 | ImpactFunction.pre_process | train | def pre_process(self):
"""Run every pre-processors.
Preprocessors are creating new layers with a specific layer_purpose.
This layer is added then to the datastore.
:return: Nothing
"""
LOGGER.info('ANALYSIS : Pre processing')
for pre_processor in self._preproce... | python | {
"resource": ""
} |
q243181 | ImpactFunction.hazard_preparation | train | def hazard_preparation(self):
"""This function is doing the hazard preparation."""
LOGGER.info('ANALYSIS : Hazard preparation')
use_same_projection = (
self.hazard.crs().authid() == self._crs.authid())
self.set_state_info(
'hazard',
'use_same_projecti... | python | {
"resource": ""
} |
q243182 | ImpactFunction.aggregate_hazard_preparation | train | def aggregate_hazard_preparation(self):
"""This function is doing the aggregate hazard layer.
It will prepare the aggregate layer and intersect hazard polygons with
aggregation areas and assign hazard class.
"""
LOGGER.info('ANALYSIS : Aggregate hazard preparation')
self... | python | {
"resource": ""
} |
q243183 | ImpactFunction.exposure_preparation | train | def exposure_preparation(self):
"""This function is doing the exposure preparation."""
LOGGER.info('ANALYSIS : Exposure preparation')
use_same_projection = (
self.exposure.crs().authid() == self._crs.authid())
self.set_state_info(
'exposure',
'use_sam... | python | {
"resource": ""
} |
q243184 | ImpactFunction.intersect_exposure_and_aggregate_hazard | train | def intersect_exposure_and_aggregate_hazard(self):
"""This function intersects the exposure with the aggregate hazard.
If the the exposure is a continuous raster exposure, this function
will set the aggregate hazard layer.
However, this function will set the impact layer.
""... | python | {
"resource": ""
} |
q243185 | ImpactFunction.post_process | train | def post_process(self, layer):
"""More process after getting the impact layer with data.
:param layer: The vector layer to use for post processing.
:type layer: QgsVectorLayer
"""
LOGGER.info('ANALYSIS : Post processing')
# Set the layer title
purpose = layer.ke... | python | {
"resource": ""
} |
q243186 | ImpactFunction.summary_calculation | train | def summary_calculation(self):
"""Do the summary calculation.
We do not check layers here, we will check them in the next step.
"""
LOGGER.info('ANALYSIS : Summary calculation')
if is_vector_layer(self._exposure_summary):
# With continuous exposure, we don't have an ... | python | {
"resource": ""
} |
q243187 | ImpactFunction.style | train | def style(self):
"""Function to apply some styles to the layers."""
LOGGER.info('ANALYSIS : Styling')
classes = generate_classified_legend(
self.analysis_impacted,
self.exposure,
self.hazard,
self.use_rounding,
self.debug_mode)
... | python | {
"resource": ""
} |
q243188 | ImpactFunction.exposure_notes | train | def exposure_notes(self):
"""Get the exposure specific notes defined in definitions.
This method will do a lookup in definitions and return the
exposure definition specific notes dictionary.
This is a helper function to make it
easy to get exposure specific notes from the defin... | python | {
"resource": ""
} |
q243189 | ImpactFunction.hazard_notes | train | def hazard_notes(self):
"""Get the hazard specific notes defined in definitions.
This method will do a lookup in definitions and return the
hazard definition specific notes dictionary.
This is a helper function to make it
easy to get hazard specific notes from the definitions m... | python | {
"resource": ""
} |
q243190 | ImpactFunction.notes | train | def notes(self):
"""Return the notes section of the report.
.. versionadded:: 3.5
:return: The notes that should be attached to this impact report.
:rtype: list
"""
fields = [] # Notes still to be defined for ASH
# include any generic exposure specific notes fr... | python | {
"resource": ""
} |
q243191 | ImpactFunction.action_checklist | train | def action_checklist(self):
"""Return the list of action check list dictionary.
:return: The list of action check list dictionary.
:rtype: list
"""
actions = []
exposure = definition(self.exposure.keywords.get('exposure'))
actions.extend(exposure.get('actions'))
... | python | {
"resource": ""
} |
q243192 | memory_error | train | def memory_error():
"""Display an error when there is not enough memory."""
warning_heading = m.Heading(
tr('Memory issue'), **WARNING_STYLE)
warning_message = tr(
'There is not enough free memory to run this analysis.')
suggestion_heading = m.Heading(
tr('Suggestion'), **SUGGEST... | python | {
"resource": ""
} |
q243193 | create_top_level_index_entry | train | def create_top_level_index_entry(title, max_depth, subtitles):
"""Function for creating a text entry in index.rst for its content.
:param title : Title for the content.
:type title: str
:param max_depth : Value for max_depth in the top level index content.
:type max_depth: int
:param subtitle... | python | {
"resource": ""
} |
q243194 | create_package_level_rst_index_file | train | def create_package_level_rst_index_file(
package_name, max_depth, modules, inner_packages=None):
"""Function for creating text for index for a package.
:param package_name: name of the package
:type package_name: str
:param max_depth: Value for max_depth in the index file.
:type max_depth:... | python | {
"resource": ""
} |
q243195 | create_module_rst_file | train | def create_module_rst_file(module_name):
"""Function for creating content in each .rst file for a module.
:param module_name: name of the module.
:type module_name: str
:returns: A content for auto module.
:rtype: str
"""
return_text = 'Module: ' + module_name
dash = '=' * len(return... | python | {
"resource": ""
} |
q243196 | write_rst_file | train | def write_rst_file(file_directory, file_name, content):
"""Shorter procedure for creating rst file.
:param file_directory: Directory of the filename.
:type file_directory: str
:param file_name: Name of the file.
:type file_name: str
:param content: The content of the file.
:type content: ... | python | {
"resource": ""
} |
q243197 | get_python_files_from_list | train | def get_python_files_from_list(files, excluded_files=None):
"""Return list of python file from files, without excluded files.
:param files: List of files.
:type files: list
:param excluded_files: List of excluded file names.
:type excluded_files: list, None
:returns: List of python file witho... | python | {
"resource": ""
} |
q243198 | get_inasafe_code_path | train | def get_inasafe_code_path(custom_inasafe_path=None):
"""Determine the path to inasafe location.
:param custom_inasafe_path: Custom inasafe project location.
:type custom_inasafe_path: str
:returns: Path to inasafe source code.
:rtype: str
"""
inasafe_code_path = os.path.abspath(
o... | python | {
"resource": ""
} |
q243199 | clean_api_docs_dirs | train | def clean_api_docs_dirs():
"""Empty previous api-docs directory.
:returns: Path to api-docs directory.
:rtype: str
"""
inasafe_docs_path = os.path.abspath(
os.path.join(
os.path.dirname(__file__), '..', 'docs', 'api-docs'))
if os.path.exists(inasafe_docs_path):
rmtre... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.