INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Clone a part.
.. versionadded:: 2.3
:param kwargs: (optional) additional keyword=value arguments
:type kwargs: dict
:return: cloned :class:`models.Part`
:raises APIError: if the `Part` could not be cloned
Example
-------
>>> bike = client.model('Bike')
... | def clone(self, **kwargs):
"""
Clone a part.
.. versionadded:: 2.3
:param kwargs: (optional) additional keyword=value arguments
:type kwargs: dict
:return: cloned :class:`models.Part`
:raises APIError: if the `Part` could not be cloned
Example
-... |
Copy the `Part` to target parent, both of them having the same category.
.. versionadded:: 2.3
:param target_parent: `Part` object under which the desired `Part` is copied
:type target_parent: :class:`Part`
:param name: how the copied top-level `Part` should be called
:type nam... | def copy(self, target_parent, name=None, include_children=True, include_instances=True):
"""
Copy the `Part` to target parent, both of them having the same category.
.. versionadded:: 2.3
:param target_parent: `Part` object under which the desired `Part` is copied
:type target_... |
Move the `Part` to target parent, both of them the same category.
.. versionadded:: 2.3
:param target_parent: `Part` object under which the desired `Part` is moved
:type target_parent: :class:`Part`
:param name: how the moved top-level `Part` should be called
:type name: basest... | def move(self, target_parent, name=None, include_children=True, include_instances=True):
"""
Move the `Part` to target parent, both of them the same category.
.. versionadded:: 2.3
:param target_parent: `Part` object under which the desired `Part` is moved
:type target_parent: ... |
:return: bytes | def data_to_binary(self):
"""
:return: bytes
"""
return bytes([
COMMAND_CODE,
self.channels_to_byte([self.channel])
]) + bytes(self.name, 'utf-8') |
:return: str | def to_json(self):
"""
:return: str
"""
json_dict = self.to_json_basic()
json_dict['channel'] = self.channel
return json.dumps(json_dict) |
:return: None | def populate(self, priority, address, rtr, data):
"""
:return: None
"""
assert isinstance(data, bytes)
self.needs_low_priority(priority)
self.needs_no_rtr(rtr)
self.needs_data(data, 5)
self.set_attributes(priority, address, rtr)
self.channel = data... |
Internal function that is used for generation of the notebooks footer.
----------
Parameters
----------
notebook_object : notebook object
Object of "notebook" class where the header will be created.
notebook_type : str
Notebook type: - "Main_Files_Signal_Samples"
... | def _generate_footer(notebook_object, notebook_type):
"""
Internal function that is used for generation of the notebooks footer.
----------
Parameters
----------
notebook_object : notebook object
Object of "notebook" class where the header will be created.
notebook_type : str
... |
Internal function that is used for generation of the page where notebooks are organized by
difficulty level.
----------
Parameters
----------
notebook_object : notebook object
Object of "notebook" class where the body will be created.
dict_by_difficulty : dict
Global Dictionary... | def _generate_notebook_by_difficulty_body(notebook_object, dict_by_difficulty):
"""
Internal function that is used for generation of the page where notebooks are organized by
difficulty level.
----------
Parameters
----------
notebook_object : notebook object
Object of "notebook" cl... |
Internal function intended to generate the biosignalsnotebooks directories in order to the user
can visualise and execute the Notebook created with "notebook" class in Jupyter.
----------
Parameters
----------
path : str
Path where the biosignalsnotebooks environment (files and folders) wil... | def _generate_dir_structure(path):
"""
Internal function intended to generate the biosignalsnotebooks directories in order to the user
can visualise and execute the Notebook created with "notebook" class in Jupyter.
----------
Parameters
----------
path : str
Path where the biosigna... |
Class method responsible for generating a file containing the notebook object data.
----------
Parameters
----------
path : str
biosignalsnotebooks Root folder path (where the notebook will be stored).
filename : str
Defines the name of the notebook file... | def write_to_file(self, path, filename):
"""
Class method responsible for generating a file containing the notebook object data.
----------
Parameters
----------
path : str
biosignalsnotebooks Root folder path (where the notebook will be stored).
fil... |
Check if the provided XYPoint can be recreated by a Hue lamp. | def in_lamp_reach(p):
''' Check if the provided XYPoint can be recreated by a Hue lamp. '''
v1 = XYPoint(Lime.x - Red.x, Lime.y - Red.y)
v2 = XYPoint(Blue.x - Red.x, Blue.y - Red.y)
q = XYPoint(p.x - Red.x, p.y - Red.y)
s = cross_product(q, v2) / cross_product(v1, v2)
t = cross_product(v1, q) /... |
Find the closest point on a line. This point will be reproducible by a Hue
lamp. | def get_closest_point_to_line(A, B, P):
'''
Find the closest point on a line. This point will be reproducible by a Hue
lamp.
'''
AP = XYPoint(P.x - A.x, P.y - A.y)
AB = XYPoint(B.x - A.x, B.y - A.y)
ab2 = AB.x * AB.x + AB.y * AB.y
ap_ab = AP.x * AB.x + AP.y * AB.y
t = ap_ab / ab2
... |
Used to find the closest point to an unreproducible Color is unreproducible
on each line in the CIE 1931 'triangle'. | def get_closest_point_to_point(xy_point):
'''
Used to find the closest point to an unreproducible Color is unreproducible
on each line in the CIE 1931 'triangle'.
'''
pAB = get_closest_point_to_line(Red, Lime, xy_point)
pAC = get_closest_point_to_line(Blue, Red, xy_point)
pBC = get_closest_p... |
Returns X, Y coordinates containing the closest avilable CIE 1931
based on the hex_value provided. | def get_xy_from_hex(hex_value):
'''
Returns X, Y coordinates containing the closest avilable CIE 1931
based on the hex_value provided.
'''
red, green, blue = struct.unpack('BBB', codecs.decode(hex_value, 'hex'))
r = ((red + 0.055) / (1.0 + 0.055)) ** 2.4 if (red > 0.04045) else (red / 12.92) # ... |
Returns list of other keys that are mapped to the same value as specified key.
@param key - key for which other keys should be returned.
@param including_current if set to True - key will also appear on this list. | def get_other_keys(self, key, including_current=False):
""" Returns list of other keys that are mapped to the same value as specified key.
@param key - key for which other keys should be returned.
@param including_current if set to True - key will also appear on this list."""
... |
Returns an iterator over the dictionary's (key, value) pairs.
@param key_type if specified, iterator will be returning only (key,value) pairs for this type of key.
Otherwise (if not specified) ((keys,...), value)
i.e. (tuple of keys, values) pairs for all items in t... | def iteritems(self, key_type=None, return_all_keys=False):
""" Returns an iterator over the dictionary's (key, value) pairs.
@param key_type if specified, iterator will be returning only (key,value) pairs for this type of key.
Otherwise (if not specified) ((keys,...), value)
... |
Returns an iterator over the dictionary's keys.
@param key_type if specified, iterator for a dictionary of this type will be used.
Otherwise (if not specified) tuples containing all (multiple) keys
for this dictionary will be generated.
@param return_al... | def iterkeys(self, key_type=None, return_all_keys=False):
""" Returns an iterator over the dictionary's keys.
@param key_type if specified, iterator for a dictionary of this type will be used.
Otherwise (if not specified) tuples containing all (multiple) keys
... |
Returns an iterator over the dictionary's values.
@param key_type if specified, iterator will be returning only values pointed by keys of this type.
Otherwise (if not specified) all values in this dictinary will be generated. | def itervalues(self, key_type=None):
""" Returns an iterator over the dictionary's values.
@param key_type if specified, iterator will be returning only values pointed by keys of this type.
Otherwise (if not specified) all values in this dictinary will be generated."""
... |
Returns a copy of the dictionary's keys.
@param key_type if specified, only keys for this type will be returned.
Otherwise list of tuples containing all (multiple) keys will be returned. | def keys(self, key_type=None):
""" Returns a copy of the dictionary's keys.
@param key_type if specified, only keys for this type will be returned.
Otherwise list of tuples containing all (multiple) keys will be returned."""
if key_type is not None:
intermed... |
Returns a copy of the dictionary's values.
@param key_type if specified, only values pointed by keys of this type will be returned.
Otherwise list of all values contained in this dictionary will be returned. | def values(self, key_type=None):
""" Returns a copy of the dictionary's values.
@param key_type if specified, only values pointed by keys of this type will be returned.
Otherwise list of all values contained in this dictionary will be returned."""
if(key_type is not None... |
Internal method to add an item to the multi-key dictionary | def __add_item(self, item, keys=None):
""" Internal method to add an item to the multi-key dictionary"""
if(not keys or not len(keys)):
raise Exception('Error in %s.__add_item(%s, keys=tuple/list of items): need to specify a tuple/list containing at least one key!'
... |
Return the value at index specified as key. | def get(self, key, default=None):
""" Return the value at index specified as key."""
if key in self:
return self.items_dict[self.__dict__[str(type(key))][key]]
else:
return default |
Extract messages from Django template string. | def extract_translations(self, string):
"""Extract messages from Django template string."""
trans = []
for t in Lexer(string.decode("utf-8"), None).tokenize():
if t.token_type == TOKEN_BLOCK:
if not t.contents.startswith(
(self.tranz_tag, self... |
Returns the next marker.
Returns:
tuple: The marker name as a string and its genotypes as a
:py:class:`numpy.ndarray`. | def next(self):
"""Returns the next marker.
Returns:
tuple: The marker name as a string and its genotypes as a
:py:class:`numpy.ndarray`.
"""
if self._mode != "r":
raise UnsupportedOperation("not available in 'w' mode")
self._n += 1
... |
Reads the current marker and returns its genotypes. | def _read_current_marker(self):
"""Reads the current marker and returns its genotypes."""
return self._geno_values[
np.frombuffer(self._bed.read(self._nb_bytes), dtype=np.uint8)
].flatten(order="C")[:self._nb_samples] |
Gets to a certain marker position in the BED file.
Args:
n (int): The index of the marker to seek to. | def seek(self, n):
"""Gets to a certain marker position in the BED file.
Args:
n (int): The index of the marker to seek to.
"""
if self._mode != "r":
raise UnsupportedOperation("not available in 'w' mode")
if 0 <= n < self._nb_markers:
self.... |
Reads the BIM file. | def _read_bim(self):
"""Reads the BIM file."""
# Reading the BIM file and setting the values
bim = pd.read_csv(self.bim_filename, delim_whitespace=True,
names=["chrom", "snp", "cm", "pos", "a1", "a2"],
dtype=dict(snp=str, a1=str, a2=str))
... |
Reads the FAM file. | def _read_fam(self):
"""Reads the FAM file."""
# Reading the FAM file and setting the values
fam = pd.read_csv(self.fam_filename, delim_whitespace=True,
names=["fid", "iid", "father", "mother", "gender",
"status"],
... |
Reads the BED file. | def _read_bed(self):
"""Reads the BED file."""
# Checking if BIM and BAM files were both read
if (self._bim is None) or (self._fam is None):
raise RuntimeError("no BIM or FAM file were read")
# The number of bytes per marker
self._nb_bytes = int(np.ceil(self._nb_samp... |
Writes the BED first 3 bytes. | def _write_bed_header(self):
"""Writes the BED first 3 bytes."""
# Writing the first three bytes
final_byte = 1 if self._bed_format == "SNP-major" else 0
self._bed.write(bytearray((108, 27, final_byte))) |
Iterates over genotypes (ACGT format).
Returns:
tuple: The name of the marker as a string, and its genotypes as a
:py:class:`numpy.ndarray` (ACGT format). | def iter_acgt_geno(self):
"""Iterates over genotypes (ACGT format).
Returns:
tuple: The name of the marker as a string, and its genotypes as a
:py:class:`numpy.ndarray` (ACGT format).
"""
# Need to iterate over itself, and modify the actual genotypes
for... |
Iterates over genotypes for a list of markers.
Args:
markers (list): The list of markers to iterate onto.
return_index (bool): Wether to return the marker's index or not.
Returns:
tuple: The name of the marker as a string, and its genotypes as a
:py:clas... | def iter_geno_marker(self, markers, return_index=False):
"""Iterates over genotypes for a list of markers.
Args:
markers (list): The list of markers to iterate onto.
return_index (bool): Wether to return the marker's index or not.
Returns:
tuple: The name of... |
Iterates over genotypes for a list of markers (ACGT format).
Args:
markers (list): The list of markers to iterate onto.
Returns:
tuple: The name of the marker as a string, and its genotypes as a
:py:class:`numpy.ndarray` (ACGT format). | def iter_acgt_geno_marker(self, markers):
"""Iterates over genotypes for a list of markers (ACGT format).
Args:
markers (list): The list of markers to iterate onto.
Returns:
tuple: The name of the marker as a string, and its genotypes as a
:py:class:`numpy.n... |
Gets the genotypes for a given marker.
Args:
marker (str): The name of the marker.
return_index (bool): Wether to return the marker's index or not.
Returns:
numpy.ndarray: The genotypes of the marker (additive format). | def get_geno_marker(self, marker, return_index=False):
"""Gets the genotypes for a given marker.
Args:
marker (str): The name of the marker.
return_index (bool): Wether to return the marker's index or not.
Returns:
numpy.ndarray: The genotypes of the marker ... |
Gets the genotypes for a given marker (ACGT format).
Args:
marker (str): The name of the marker.
Returns:
numpy.ndarray: The genotypes of the marker (ACGT format). | def get_acgt_geno_marker(self, marker):
"""Gets the genotypes for a given marker (ACGT format).
Args:
marker (str): The name of the marker.
Returns:
numpy.ndarray: The genotypes of the marker (ACGT format).
"""
# Getting the marker's genotypes
g... |
Write genotypes to binary file.
Args:
genotypes (numpy.ndarray): The genotypes to write in the BED file. | def write_genotypes(self, genotypes):
"""Write genotypes to binary file.
Args:
genotypes (numpy.ndarray): The genotypes to write in the BED file.
"""
if self._mode != "w":
raise UnsupportedOperation("not available in 'r' mode")
# Initializing the number... |
Collect data into fixed-length chunks or blocks.
Args:
n (int): The size of the chunk.
fillvalue (int): The fill value.
Returns:
iterator: An iterator over the chunks. | def _grouper(iterable, n, fillvalue=0):
"""Collect data into fixed-length chunks or blocks.
Args:
n (int): The size of the chunk.
fillvalue (int): The fill value.
Returns:
iterator: An iterator over the chunks.
"""
args = [iter(iterable)] * ... |
Generic Time Series Read from File Method | def _read(self, directory, filename, session, path, name, extension, spatial=None, spatialReferenceID=None, replaceParamFile=None):
"""
Generic Time Series Read from File Method
"""
# Assign file extension attribute to file object
self.fileExtension = extension
timeSerie... |
Generic Time Series Write to File Method | def _write(self, session, openFile, replaceParamFile):
"""
Generic Time Series Write to File Method
"""
# Retrieve all time series
timeSeries = self.timeSeries
# Num TimeSeries
numTS = len(timeSeries)
# Transform into list of dictionaries for pivot tool
... |
Return time series as pandas dataframe | def as_dataframe(self):
"""
Return time series as pandas dataframe
"""
time_series = {}
for ts_index, ts in enumerate(self.timeSeries):
index = []
data = []
for value in ts.values:
index.append(value.simTime)
dat... |
Create GSSHAPY TimeSeries and TimeSeriesValue Objects Method | def _createTimeSeriesObjects(self, timeSeries, filename):
"""
Create GSSHAPY TimeSeries and TimeSeriesValue Objects Method
"""
try:
# Determine number of value columns
valColumns = len(timeSeries[0]['values'])
# Create List of GSSHAPY TimeSeries objec... |
Creates a :class:`Blueprint.cls` and calls each deferred operation.
:param obj:
The initialized object with which to call all deferred operations.
:type obj: object
:param memo:
A dictionary to cache registered Blueprints.
:type memo: dict[Blueprint,T]
... | def register(self, obj=None, memo=None):
"""
Creates a :class:`Blueprint.cls` and calls each deferred operation.
:param obj:
The initialized object with which to call all deferred operations.
:type obj: object
:param memo:
A dictionary to cache registere... |
Extends deferred operations calling each operation of given Blueprints.
:param blues:
Blueprints or Dispatchers to extend deferred operations.
:type blues: Blueprint | schedula.dispatcher.Dispatcher
:param memo:
A dictionary to cache Blueprints.
:type memo: dict... | def extend(self, *blues, memo=None):
"""
Extends deferred operations calling each operation of given Blueprints.
:param blues:
Blueprints or Dispatchers to extend deferred operations.
:type blues: Blueprint | schedula.dispatcher.Dispatcher
:param memo:
A... |
Add a single data node to the dispatcher.
:param data_id:
Data node id. If None will be assigned automatically ('unknown<%d>')
not in dmap.
:type data_id: str, optional
:param default_value:
Data node default value. This will be used as input if it is not
... | def add_data(self, data_id=None, default_value=EMPTY, initial_dist=0.0,
wait_inputs=False, wildcard=None, function=None, callback=None,
description=None, filters=None, await_result=None, **kwargs):
"""
Add a single data node to the dispatcher.
:param data_id:
... |
Add a single function node to dispatcher.
:param function_id:
Function node id.
If None will be assigned as <fun.__name__>.
:type function_id: str, optional
:param function:
Data node estimation function.
:type function: callable, optional
:... | def add_function(self, function_id=None, function=None, inputs=None,
outputs=None, input_domain=None, weight=None,
inp_weight=None, out_weight=None, description=None,
filters=None, await_domain=None, await_result=None,
**kwargs):
... |
Add a single function node to dispatcher.
:param inputs_kwargs:
Do you want to include kwargs as inputs?
:type inputs_kwargs: bool
:param inputs_defaults:
Do you want to set default values?
:type inputs_defaults: bool
:param function_id:
Fun... | def add_func(self, function, outputs=None, weight=None, inputs_kwargs=False,
inputs_defaults=False, filters=None, input_domain=None,
await_domain=None, await_result=None, inp_weight=None,
out_weight=None, description=None, inputs=None,
function_id=None... |
Add a single sub-dispatcher node to dispatcher.
:param dsp:
Child dispatcher that is added as sub-dispatcher node to the parent
dispatcher.
:type dsp: Dispatcher | dict[str, list]
:param inputs:
Inputs mapping. Data node ids from parent dispatcher to child
... | def add_dispatcher(self, dsp, inputs, outputs, dsp_id=None,
input_domain=None, weight=None, inp_weight=None,
description=None, include_defaults=False,
await_domain=None, **kwargs):
"""
Add a single sub-dispatcher node to dispatcher.
... |
Add multiple function and data nodes to dispatcher.
:param data_list:
It is a list of data node kwargs to be loaded.
:type data_list: list[dict], optional
:param fun_list:
It is a list of function node kwargs to be loaded.
:type fun_list: list[dict], optional
... | def add_from_lists(self, data_list=None, fun_list=None, dsp_list=None):
"""
Add multiple function and data nodes to dispatcher.
:param data_list:
It is a list of data node kwargs to be loaded.
:type data_list: list[dict], optional
:param fun_list:
It is ... |
Set the default value of a data node in the dispatcher.
:param data_id:
Data node id.
:type data_id: str
:param value:
Data node default value.
.. note:: If `EMPTY` the previous default value is removed.
:type value: T, optional
:param init... | def set_default_value(self, data_id, value=EMPTY, initial_dist=0.0):
"""
Set the default value of a data node in the dispatcher.
:param data_id:
Data node id.
:type data_id: str
:param value:
Data node default value.
.. note:: If `EMPTY` the... |
Generic Output Location Read from File Method | def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, replaceParamFile):
"""
Generic Output Location Read from File Method
"""
# Assign file extension attribute to file object
self.fileExtension = extension
# Open file and pars... |
Generic Output Location Write to File Method | def _write(self, session, openFile, replaceParamFile):
"""
Generic Output Location Write to File Method
"""
# Retrieve output locations
locations = self.outputLocations
# Write lines
openFile.write('%s\n' % self.numLocations)
for location in locations:
... |
Creates a dispatcher Flask app.
:param depth:
Depth of sub-dispatch plots. If negative all levels are plotted.
:type depth: int, optional
:param node_data:
Data node attributes to view.
:type node_data: tuple[str], optional
:param node_function:
... | def web(self, depth=-1, node_data=NONE, node_function=NONE, directory=None,
sites=None, run=True):
"""
Creates a dispatcher Flask app.
:param depth:
Depth of sub-dispatch plots. If negative all levels are plotted.
:type depth: int, optional
:param node_d... |
Plots the Dispatcher with a graph in the DOT language with Graphviz.
:param workflow:
If True the latest solution will be plotted, otherwise the dmap.
:type workflow: bool, optional
:param view:
Open the rendered directed graph in the DOT language with the sys
... | def plot(self, workflow=None, view=True, depth=-1, name=NONE, comment=NONE,
format=NONE, engine=NONE, encoding=NONE, graph_attr=NONE,
node_attr=NONE, edge_attr=NONE, body=NONE, node_styles=NONE,
node_data=NONE, node_function=NONE, edge_data=NONE, max_lines=NONE,
max_w... |
Returns a sub node of a dispatcher.
:param node_ids:
A sequence of node ids or a single node id. The id order identifies
a dispatcher sub-level.
:type node_ids: str
:param node_attr:
Output node attr.
If the searched node does not have this attr... | def get_node(self, *node_ids, node_attr=NONE):
"""
Returns a sub node of a dispatcher.
:param node_ids:
A sequence of node ids or a single node id. The id order identifies
a dispatcher sub-level.
:type node_ids: str
:param node_attr:
Output n... |
A convenience wrapper for _get. Adds headers, auth and base url by
default | def _api_get(self, url, **kwargs):
"""
A convenience wrapper for _get. Adds headers, auth and base url by
default
"""
kwargs['url'] = self.url + url
kwargs['auth'] = self.auth
headers = deepcopy(self.headers)
headers.update(kwargs.get('headers', {}))
... |
A wrapper for getting things
:returns: The response of your get
:rtype: dict | def _get(self, *args, **kwargs):
"""
A wrapper for getting things
:returns: The response of your get
:rtype: dict
"""
response = requests.get(*args, **kwargs)
response.raise_for_status()
return response.json() |
A convenience wrapper for _put. Adds headers, auth and base url by
default | def _api_put(self, url, **kwargs):
"""
A convenience wrapper for _put. Adds headers, auth and base url by
default
"""
kwargs['url'] = self.url + url
kwargs['auth'] = self.auth
headers = deepcopy(self.headers)
headers.update(kwargs.get('headers', {}))
... |
A wrapper for putting things. It will also json encode your 'data' parameter
:returns: The response of your put
:rtype: dict | def _put(self, *args, **kwargs):
"""
A wrapper for putting things. It will also json encode your 'data' parameter
:returns: The response of your put
:rtype: dict
"""
if 'data' in kwargs:
kwargs['data'] = json.dumps(kwargs['data'])
response = requests.... |
A convenience wrapper for _post. Adds headers, auth and base url by
default | def _api_post(self, url, **kwargs):
"""
A convenience wrapper for _post. Adds headers, auth and base url by
default
"""
kwargs['url'] = self.url + url
kwargs['auth'] = self.auth
headers = deepcopy(self.headers)
headers.update(kwargs.get('headers', {}))
... |
A wrapper for posting things. It will also json encode your 'data' parameter
:returns: The response of your post
:rtype: dict | def _post(self, *args, **kwargs):
"""
A wrapper for posting things. It will also json encode your 'data' parameter
:returns: The response of your post
:rtype: dict
"""
if 'data' in kwargs:
kwargs['data'] = json.dumps(kwargs['data'])
response = request... |
A convenience wrapper for _delete. Adds headers, auth and base url by
default | def _api_delete(self, url, **kwargs):
"""
A convenience wrapper for _delete. Adds headers, auth and base url by
default
"""
kwargs['url'] = self.url + url
kwargs['auth'] = self.auth
headers = deepcopy(self.headers)
headers.update(kwargs.get('headers', {})... |
A wrapper for deleting things
:returns: The response of your delete
:rtype: dict | def _delete(self, *args, **kwargs):
"""
A wrapper for deleting things
:returns: The response of your delete
:rtype: dict
"""
response = requests.delete(*args, **kwargs)
response.raise_for_status() |
Searches for translations files matching [catalog].[lang].[format]
Traverses TRANZ_LOCALE_PATHS:
-
| TRANZ_LOCALE_PATHS
+- messages.fr.yml
| messages.en.yml
And apps paths if TRANZ_SEARCH_LOCALE_IN_APPS is set to True):
-
| app_path
+- TRANZ_DIR_NAME
+- messages.fr.yml
... | def discover_resources():
"""
Searches for translations files matching [catalog].[lang].[format]
Traverses TRANZ_LOCALE_PATHS:
-
| TRANZ_LOCALE_PATHS
+- messages.fr.yml
| messages.en.yml
And apps paths if TRANZ_SEARCH_LOCALE_IN_APPS is set to True):
-
| app_path
+- TRANZ... |
Retrieve the raster as a KML document with each cell of the raster represented as a vector polygon. The result
is a vector grid of raster cells. Cells with the no data value are excluded.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object bound to PostGIS enabl... | def getAsKmlGrid(self, session, path=None, documentName=None, colorRamp=ColorRampEnum.COLOR_RAMP_HUE, alpha=1.0,
noDataValue=None):
"""
Retrieve the raster as a KML document with each cell of the raster represented as a vector polygon. The result
is a vector grid of raster c... |
Retrieve the raster in the GRASS ASCII Grid format.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object bound to PostGIS enabled database.
Returns:
str: GRASS ASCII string. | def getAsGrassAsciiGrid(self, session):
"""
Retrieve the raster in the GRASS ASCII Grid format.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object bound to PostGIS enabled database.
Returns:
str: GRASS ASCII string.
"""
... |
Retrieve the raster as a PNG image ground overlay KML format. Coarse grid resolutions must be resampled to
smaller cell/pixel sizes to avoid a "fuzzy" look. Cells with the no data value are excluded.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session object bound to P... | def getAsKmlPng(self, session, path=None, documentName=None, colorRamp=ColorRampEnum.COLOR_RAMP_HUE, alpha=1.0,
noDataValue=None, drawOrder=0, cellSize=None, resampleMethod='NearestNeighbour'):
"""
Retrieve the raster as a PNG image ground overlay KML format. Coarse grid resolutions ... |
This function initializes the context of execution deciding which
type of threads are being used: classic python threads or green
threads, provided by Gevent.
This should be called first of all in every execution, otherwise,
the library would not work.
The default module is 'thread'.
:param s... | def set_context(module_name='thread'):
'''
This function initializes the context of execution deciding which
type of threads are being used: classic python threads or green
threads, provided by Gevent.
This should be called first of all in every execution, otherwise,
the library would not work.... |
This is the main function to create a new Host to which you can
spawn actors. It will be set by default at local address if no
parameter *url* is given, which would result in remote
incomunication between hosts. This function shuould be called once
for execution or after callig :meth:`~.shutdown` to the... | def create_host(url="local://local:6666/host"):
'''
This is the main function to create a new Host to which you can
spawn actors. It will be set by default at local address if no
parameter *url* is given, which would result in remote
incomunication between hosts. This function shuould be called once... |
Stops the Host passed by parameter or all of them if none is
specified, stopping at the same time all its actors.
Should be called at the end of its usage, to finish correctly
all the connections and threads. | def shutdown(url=None):
'''
Stops the Host passed by parameter or all of them if none is
specified, stopping at the same time all its actors.
Should be called at the end of its usage, to finish correctly
all the connections and threads.
'''
if url is None:
for host in util.hosts.valu... |
This allows the host (main host) to keep alive indefinitely so its actors
can receive queries at any time.
The main thread stays blocked forever.
To kill the execution, press Ctrl+C.
See usage example in :ref:`sample6`. | def serve_forever():
'''
This allows the host (main host) to keep alive indefinitely so its actors
can receive queries at any time.
The main thread stays blocked forever.
To kill the execution, press Ctrl+C.
See usage example in :ref:`sample6`.
'''
if not util.main_host.alive:
r... |
Creates an Event attached to the host for management that will
execute the *method* of the *actor* every *time* seconds.
See example in :ref:`sample_inter`
:param Proxy host: host that will manage the interval, commonly the
host of the actor.
:param int time: seconds for the intervals.
:pa... | def interval(host, time, actor, method, *args, **kwargs):
'''Creates an Event attached to the host for management that will
execute the *method* of the *actor* every *time* seconds.
See example in :ref:`sample_inter`
:param Proxy host: host that will manage the interval, commonly the
host of t... |
Sets a timer that will call the *method* of the *actor* past *timeout*
seconds.
See example in :ref:`sample_inter`
:param int timeout: seconds until the method is called.
:param Proxy actor: actor to which make the call after *time* seconds.
:param Str. method: method of the *actor* to be called.
... | def later(timeout, actor, method, *args, **kwargs):
'''
Sets a timer that will call the *method* of the *actor* past *timeout*
seconds.
See example in :ref:`sample_inter`
:param int timeout: seconds until the method is called.
:param Proxy actor: actor to which make the call after *time* secon... |
For remote communication. Sets the communication dispatcher of the host
at the address and port specified.
The scheme must be http if using a XMLRPC dispatcher.
amqp for RabbitMQ communications.
This methos is internal. Automatically called when creating the host.
:param str. ... | def load_transport(self, url):
'''
For remote communication. Sets the communication dispatcher of the host
at the address and port specified.
The scheme must be http if using a XMLRPC dispatcher.
amqp for RabbitMQ communications.
This methos is internal. Automatically c... |
This method creates an actor attached to this host. It will be
an instance of the class *klass* and it will be assigned an ID
that identifies it among the host.
This method can be called remotely synchronously.
:param str. aid: identifier for the spawning actor. Unique within
... | def spawn(self, aid, klass, *param, **kparam):
'''
This method creates an actor attached to this host. It will be
an instance of the class *klass* and it will be assigned an ID
that identifies it among the host.
This method can be called remotely synchronously.
:param s... |
Checks if the given id is used in the host by some actor.
:param str. aid: identifier of the actor to check.
:return: True if the id is used within the host. | def has_actor(self, aid):
'''
Checks if the given id is used in the host by some actor.
:param str. aid: identifier of the actor to check.
:return: True if the id is used within the host.
'''
url = '%s://%s/%s' % (self.transport, self.host_url.netloc, aid)
return... |
Gets a new proxy that references to the actor of this host
(only actors in this host) identified by the given ID.
This method can be called remotely synchronously.
:param str. aid: identifier of the actor you want.
:return: :class:`~.Proxy` of the actor requiered.
:raises: :cla... | def lookup(self, aid):
'''
Gets a new proxy that references to the actor of this host
(only actors in this host) identified by the given ID.
This method can be called remotely synchronously.
:param str. aid: identifier of the actor you want.
:return: :class:`~.Proxy` of... |
This method removes one actor from the Host, stoping it and deleting
all its references.
:param str. aid: identifier of the actor you want to stop. | def stop_actor(self, aid):
'''
This method removes one actor from the Host, stoping it and deleting
all its references.
:param str. aid: identifier of the actor you want to stop.
'''
url = '%s://%s/%s' % (self.transport, self.host_url.netloc, aid)
if url != self.... |
Gets a proxy reference to the actor indicated by the URL in the
parameters. It can be a local reference or a remote direction to
another host.
This method can be called remotely synchronously.
:param srt. url: address that identifies an actor.
:param class klass: the class of t... | def lookup_url(self, url, klass, module=None):
'''
Gets a proxy reference to the actor indicated by the URL in the
parameters. It can be a local reference or a remote direction to
another host.
This method can be called remotely synchronously.
:param srt. url: address t... |
Checks the parameters generating new proxy instances to avoid
query concurrences from shared proxies and creating proxies for
actors from another host. | def dumps(self, param):
'''
Checks the parameters generating new proxy instances to avoid
query concurrences from shared proxies and creating proxies for
actors from another host.
'''
if isinstance(param, Proxy):
module_name = param.actor.klass.__module__
... |
Checks the return parameters generating new proxy instances to
avoid query concurrences from shared proxies and creating
proxies for actors from another host. | def loads(self, param):
'''
Checks the return parameters generating new proxy instances to
avoid query concurrences from shared proxies and creating
proxies for actors from another host.
'''
if isinstance(param, ProxyRef):
try:
return self.look... |
Register a new thread executing a parallel method. | def new_parallel(self, function, *params):
'''
Register a new thread executing a parallel method.
'''
# Create a pool if not created (processes or Gevent...)
if self.ppool is None:
if core_type == 'thread':
from multiprocessing.pool import ThreadPool
... |
Parse the ``config_uri`` into a :class:`plaster.PlasterURL` object.
``config_uri`` can be a relative or absolute file path such as
``development.ini`` or ``/path/to/development.ini``. The file must have
an extension that can be handled by a :class:`plaster.ILoader`
registered with the system.
Alte... | def parse_uri(config_uri):
"""
Parse the ``config_uri`` into a :class:`plaster.PlasterURL` object.
``config_uri`` can be a relative or absolute file path such as
``development.ini`` or ``/path/to/development.ini``. The file must have
an extension that can be handled by a :class:`plaster.ILoader`
... |
Recursively iterate a directory. Invoke callbacks for directories
and entries (both are optional, but it doesn't make sense unless one is
provided). "max_listing_size" will allow for the file-listing to be
chunked into manageable pieces. "max_depth" limited how deep recursion
goes. T... | def recurse(self, root_path, dir_cb, listing_cb, max_listing_size=0,
max_depth=MAX_REMOTE_RECURSION_DEPTH):
"""Recursively iterate a directory. Invoke callbacks for directories
and entries (both are optional, but it doesn't make sense unless one is
provided). "max_listing_size... |
Open a remote file and write it locally. | def write_to_local(self, filepath_from, filepath_to, mtime_dt=None):
"""Open a remote file and write it locally."""
self.__log.debug("Writing R[%s] -> L[%s]." % (filepath_from,
filepath_to))
with SftpFile(self, filepath_from, 'r') as sf_fr... |
Open a local file and write it remotely. | def write_to_remote(self, filepath_from, filepath_to, mtime_dt=None):
"""Open a local file and write it remotely."""
self.__log.debug("Writing L[%s] -> R[%s]." % (filepath_from,
filepath_to))
with open(filepath_from, 'rb') as file_from:
... |
Convert an "outer" access mode to an "inner" access mode.
Returns a tuple of:
(<system access mode>, <is append>, <is universal newlines>). | def __at_om_to_im(self, om):
"""Convert an "outer" access mode to an "inner" access mode.
Returns a tuple of:
(<system access mode>, <is append>, <is universal newlines>).
"""
original_om = om
if om[0] == 'U':
om = om[1:]
is_um = Tru... |
This is the only way to open a file resource. | def open(self):
"""This is the only way to open a file resource."""
self.__sf = _sftp_open(self.__sftp_session_int,
self.__filepath,
self.access_type_int,
self.__create_mode)
if self.access_type_is_... |
Read a length of bytes. Return empty on EOF. If 'size' is omitted,
return whole file. | def read(self, size=None):
"""Read a length of bytes. Return empty on EOF. If 'size' is omitted,
return whole file.
"""
if size is not None:
return self.__sf.read(size)
block_size = self.__class__.__block_size
b = bytearray()
received_bytes = 0
... |
Reposition the file pointer. | def seek(self, offset, whence=SEEK_SET):
"""Reposition the file pointer."""
if whence == SEEK_SET:
self.__sf.seek(offset)
elif whence == SEEK_CUR:
self.__sf.seek(self.tell() + offset)
elif whence == SEEK_END:
self.__sf.seek(self.__sf.filesize - offset... |
Read a single line of text with EOF. | def readline(self, size=None):
"""Read a single line of text with EOF."""
# TODO: Add support for Unicode.
(line, nl) = self.__buffer.read_until_nl(self.__retrieve_data)
if self.__sf.access_type_has_universal_nl and nl is not None:
self.__newlines[nl] = True
return line |
Read more data from the file. | def __retrieve_data(self):
"""Read more data from the file."""
if self.__eof is True:
return b''
logging.debug("Reading another block.")
block = self.read(self.__block_size)
if block == b'':
self.__log.debug("We've encountered the EOF.")
... |
Cleans the boundary shapefile to that there is only one main polygon.
:param shapefile_path:
:return: | def clean_boundary_shapefile(shapefile_path):
"""
Cleans the boundary shapefile to that there is only one main polygon.
:param shapefile_path:
:return:
"""
wfg = gpd.read_file(shapefile_path)
first_shape = wfg.iloc[0].geometry
if hasattr(first_shape, 'geo... |
Adds a mask from a shapefile | def set_mask_from_shapefile(self, shapefile_path, cell_size):
"""
Adds a mask from a shapefile
"""
# make sure paths are absolute as the working directory changes
shapefile_path = os.path.abspath(shapefile_path)
# ADD MASK
with tmp_chdir(self.project_directory):
... |
Adds elevation file to project | def set_elevation(self, elevation_grid_path, mask_shapefile):
"""
Adds elevation file to project
"""
# ADD ELEVATION FILE
ele_file = ElevationGridFile(project_file=self.project_manager,
session=self.db_session)
ele_file.generateFromRas... |
Adds outlet point to project | def set_outlet(self, latitude, longitude, outslope):
"""
Adds outlet point to project
"""
self.project_manager.setOutlet(latitude=latitude, longitude=longitude,
outslope=outslope) |
ADD ROUGHNESS FROM LAND COVER
See: http://www.gsshawiki.com/Project_File:Overland_Flow_%E2%80%93_Required | def set_roughness(self,
roughness=None,
land_use_grid=None,
land_use_grid_id=None,
land_use_to_roughness_table=None):
"""
ADD ROUGHNESS FROM LAND COVER
See: http://www.gsshawiki.com/Project_File:Overland_Flow... |
Initializes event for GSSHA model | def set_event(self,
simulation_start=None,
simulation_duration=None,
simulation_end=None,
rain_intensity=2,
rain_duration=timedelta(seconds=30*60),
event_type='EVENT',
):
"""
Init... |
Write project to directory | def write(self):
"""
Write project to directory
"""
# write data
self.project_manager.writeInput(session=self.db_session,
directory=self.project_directory,
name=self.project_manager.name) |
Recursively mirror the contents of "path_from" into "path_to".
"handler" should be self.mirror_to_local_no_recursion or
self.mirror_to_remote_no_recursion to represent which way the files are
moving. | def mirror(self, handler, path_from, path_to, log_files=False):
"""Recursively mirror the contents of "path_from" into "path_to".
"handler" should be self.mirror_to_local_no_recursion or
self.mirror_to_remote_no_recursion to represent which way the files are
moving.
"""
... |
Mirror a directory without descending into directories. Return a
list of subdirectory names (do not include full path). We will unlink
existing files without determining if they're just going to be
rewritten and then truncating them because it is our belief, based on
what little we c... | def mirror_to_local_no_recursion(self, path_from, path_to,
log_files=False):
"""Mirror a directory without descending into directories. Return a
list of subdirectory names (do not include full path). We will unlink
existing files without determining if the... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.