INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Grabs the next frame to finish and returns it as data and metadata. | def grab_next_to_finish(self, timeout: float=None) -> typing.List[DataAndMetadata.DataAndMetadata]:
"""Grabs the next frame to finish and returns it as data and metadata.
.. versionadded:: 1.0
:param timeout: The timeout in seconds. Pass None to use default.
:return: The list of data a... |
Set the value of a control asynchronously. | def set_control_output(self, name: str, value: float, *, options: dict=None) -> None:
"""Set the value of a control asynchronously.
:param name: The name of the control (string).
:param value: The control value (float).
:param options: A dict of custom options to pass to the instrument ... |
Return the value of a float property. | def get_property_as_float(self, name: str) -> float:
"""Return the value of a float property.
:return: The property value (float).
Raises exception if property with name doesn't exist.
.. versionadded:: 1.0
Scriptable: Yes
"""
return float(self.__instrument.ge... |
Set the value of a float property. | def set_property_as_float(self, name: str, value: float) -> None:
"""Set the value of a float property.
:param name: The name of the property (string).
:param value: The property value (float).
Raises exception if property with name doesn't exist.
.. versionadded:: 1.0
... |
Return the list of data items. | def data_items(self) -> typing.List[DataItem]:
"""Return the list of data items.
:return: The list of :py:class:`nion.swift.Facade.DataItem` objects.
.. versionadded:: 1.0
Scriptable: Yes
"""
return [DataItem(data_item) for data_item in self.__document_model.data_items... |
Return the list of display items. | def display_items(self) -> typing.List[Display]:
"""Return the list of display items.
:return: The list of :py:class:`nion.swift.Facade.Display` objects.
.. versionadded:: 1.0
Scriptable: Yes
"""
return [Display(display_item) for display_item in self.__document_model.d... |
Return the list of data items that are data sources for the data item. | def get_source_data_items(self, data_item: DataItem) -> typing.List[DataItem]:
"""Return the list of data items that are data sources for the data item.
:return: The list of :py:class:`nion.swift.Facade.DataItem` objects.
.. versionadded:: 1.0
Scriptable: Yes
"""
retur... |
Return the dependent data items the data item argument. | def get_dependent_data_items(self, data_item: DataItem) -> typing.List[DataItem]:
"""Return the dependent data items the data item argument.
:return: The list of :py:class:`nion.swift.Facade.DataItem` objects.
.. versionadded:: 1.0
Scriptable: Yes
"""
return [DataItem(... |
Create an empty data item in the library. | def create_data_item(self, title: str=None) -> DataItem:
"""Create an empty data item in the library.
:param title: The title of the data item (optional).
:return: The new :py:class:`nion.swift.Facade.DataItem` object.
:rtype: :py:class:`nion.swift.Facade.DataItem`
.. versionad... |
Create a data item in the library from an ndarray. | def create_data_item_from_data(self, data: numpy.ndarray, title: str=None) -> DataItem:
"""Create a data item in the library from an ndarray.
The data for the data item will be written to disk immediately and unloaded from memory. If you wish to delay
writing to disk and keep using the data, cr... |
Create a data item in the library from a data and metadata object. | def create_data_item_from_data_and_metadata(self, data_and_metadata: DataAndMetadata.DataAndMetadata, title: str=None) -> DataItem:
"""Create a data item in the library from a data and metadata object.
The data for the data item will be written to disk immediately and unloaded from memory. If you wish ... |
Copy a data item. | def copy_data_item(self, data_item: DataItem) -> DataItem:
"""Copy a data item.
.. versionadded:: 1.0
Scriptable: No
"""
data_item = copy.deepcopy(data_item._data_item)
self.__document_model.append_data_item(data_item)
return DataItem(data_item) |
Snapshot a data item. Similar to copy but with a data snapshot. | def snapshot_data_item(self, data_item: DataItem) -> DataItem:
"""Snapshot a data item. Similar to copy but with a data snapshot.
.. versionadded:: 1.0
Scriptable: No
"""
data_item = data_item._data_item.snapshot()
self.__document_model.append_data_item(data_item)
... |
Get ( or create ) a data group. | def get_or_create_data_group(self, title: str) -> DataGroup:
"""Get (or create) a data group.
:param title: The title of the data group.
:return: The new :py:class:`nion.swift.Facade.DataGroup` object.
:rtype: :py:class:`nion.swift.Facade.DataGroup`
.. versionadded:: 1.0
... |
Get the data item associated with hardware source and ( optional ) channel id and processor_id. Optionally create if missing. | def get_data_item_for_hardware_source(self, hardware_source, channel_id: str=None, processor_id: str=None, create_if_needed: bool=False, large_format: bool=False) -> DataItem:
"""Get the data item associated with hardware source and (optional) channel id and processor_id. Optionally create if missing.
... |
Get the data item associated with data item reference key. Optionally create if missing. | def get_data_item_for_reference_key(self, data_item_reference_key: str=None, create_if_needed: bool=False, large_format: bool=False) -> DataItem:
"""Get the data item associated with data item reference key. Optionally create if missing.
:param data_item_reference_key: The data item reference key.
... |
Get the data item with the given UUID. | def get_data_item_by_uuid(self, data_item_uuid: uuid_module.UUID) -> DataItem:
"""Get the data item with the given UUID.
.. versionadded:: 1.0
Status: Provisional
Scriptable: Yes
"""
data_item = self._document_model.get_data_item_by_uuid(data_item_uuid)
return D... |
Get the graphic with the given UUID. | def get_graphic_by_uuid(self, graphic_uuid: uuid_module.UUID) -> Graphic:
"""Get the graphic with the given UUID.
.. versionadded:: 1.0
Status: Provisional
Scriptable: Yes
"""
for display_item in self._document_model.display_items:
for graphic in display_ite... |
Return whether the library value for the given key exists. | def has_library_value(self, key: str) -> bool:
"""Return whether the library value for the given key exists.
Please consult the developer documentation for a list of valid keys.
.. versionadded:: 1.0
Scriptable: Yes
"""
desc = Metadata.session_key_map.get(key)
... |
Get the library value for the given key. | def get_library_value(self, key: str) -> typing.Any:
"""Get the library value for the given key.
Please consult the developer documentation for a list of valid keys.
.. versionadded:: 1.0
Scriptable: Yes
"""
desc = Metadata.session_key_map.get(key)
if desc is n... |
Set the library value for the given key. | def set_library_value(self, key: str, value: typing.Any) -> None:
"""Set the library value for the given key.
Please consult the developer documentation for a list of valid keys.
.. versionadded:: 1.0
Scriptable: Yes
"""
desc = Metadata.session_key_map.get(key)
... |
Delete the library value for the given key. | def delete_library_value(self, key: str) -> None:
"""Delete the library value for the given key.
Please consult the developer documentation for a list of valid keys.
.. versionadded:: 1.0
Scriptable: Yes
"""
desc = Metadata.session_key_map.get(key)
if desc is n... |
Return the list of display panels currently visible. | def all_display_panels(self) -> typing.List[DisplayPanel]:
"""Return the list of display panels currently visible.
.. versionadded:: 1.0
Scriptable: Yes
"""
return [DisplayPanel(display_panel) for display_panel in self.__document_controller.workspace_controller.display_panels] |
Return display panel with the identifier. | def get_display_panel_by_id(self, identifier: str) -> DisplayPanel:
"""Return display panel with the identifier.
.. versionadded:: 1.0
Status: Provisional
Scriptable: Yes
"""
display_panel = next(
(display_panel for display_panel in self.__document_controlle... |
Display a new data item and gives it keyboard focus. Uses existing display if it is already displayed. | def display_data_item(self, data_item: DataItem, source_display_panel=None, source_data_item=None):
"""Display a new data item and gives it keyboard focus. Uses existing display if it is already displayed.
.. versionadded:: 1.0
Status: Provisional
Scriptable: Yes
"""
fo... |
Show a dialog box and ask for a string. | def show_get_string_message_box(self, caption: str, text: str, accepted_fn, rejected_fn=None, accepted_text: str=None, rejected_text: str=None) -> None:
"""Show a dialog box and ask for a string.
Caption describes the user prompt. Text is the initial/default string.
Accepted function must be a... |
Create a data item in the library from data. | def create_data_item_from_data(self, data: numpy.ndarray, title: str=None) -> DataItem:
"""Create a data item in the library from data.
.. versionadded:: 1.0
.. deprecated:: 1.1
Use :py:meth:`~nion.swift.Facade.Library.create_data_item_from_data` instead.
Scriptable: No
... |
Create a data item in the library from the data and metadata. | def create_data_item_from_data_and_metadata(self, data_and_metadata: DataAndMetadata.DataAndMetadata, title: str=None) -> DataItem:
"""Create a data item in the library from the data and metadata.
.. versionadded:: 1.0
.. deprecated:: 1.1
Use :py:meth:`~nion.swift.Facade.Library.crea... |
Get ( or create ) a data group. | def get_or_create_data_group(self, title: str) -> DataGroup:
"""Get (or create) a data group.
.. versionadded:: 1.0
.. deprecated:: 1.1
Use :py:meth:`~nion.swift.Facade.Library.create_data_item_from_data` instead.
Scriptable: No
"""
return DataGroup(self.__do... |
Return the document windows. | def document_windows(self) -> typing.List[DocumentWindow]:
"""Return the document windows.
.. versionadded:: 1.0
Scriptable: Yes
"""
return [DocumentWindow(document_controller) for document_controller in self.__application.document_controllers] |
Create a calibration object with offset scale and units. | def create_calibration(self, offset: float=None, scale: float=None, units: str=None) -> CalibrationModule.Calibration:
"""Create a calibration object with offset, scale, and units.
:param offset: The offset of the calibration.
:param scale: The scale of the calibration.
:param units: Th... |
Create a data descriptor. | def create_data_descriptor(self, is_sequence: bool, collection_dimension_count: int, datum_dimension_count: int) -> DataAndMetadata.DataDescriptor:
"""Create a data descriptor.
:param is_sequence: whether the descriptor describes a sequence of data.
:param collection_dimension_count: the number... |
Create a data_and_metadata object from data. | def create_data_and_metadata(self, data: numpy.ndarray, intensity_calibration: CalibrationModule.Calibration = None,
dimensional_calibrations: typing.List[CalibrationModule.Calibration] = None, metadata: dict = None,
timestamp: str = None, data_descripto... |
Create a data_and_metadata object from data. | def create_data_and_metadata_from_data(self, data: numpy.ndarray, intensity_calibration: CalibrationModule.Calibration=None, dimensional_calibrations: typing.List[CalibrationModule.Calibration]=None, metadata: dict=None, timestamp: str=None) -> DataAndMetadata.DataAndMetadata:
"""Create a data_and_metadata obje... |
Create an I/ O handler that reads and writes a single data_and_metadata. | def create_data_and_metadata_io_handler(self, io_handler_delegate):
"""Create an I/O handler that reads and writes a single data_and_metadata.
:param io_handler_delegate: A delegate object :py:class:`DataAndMetadataIOHandlerInterface`
.. versionadded:: 1.0
Scriptable: No
"""
... |
Create a utility panel that can be attached to a window. | def create_panel(self, panel_delegate):
"""Create a utility panel that can be attached to a window.
.. versionadded:: 1.0
Scriptable: No
The panel_delegate should respond to the following:
(property, read-only) panel_id
(property, read-only) panel_name
... |
Return the hardware source API matching the hardware_source_id and version. | def get_hardware_source_by_id(self, hardware_source_id: str, version: str):
"""Return the hardware source API matching the hardware_source_id and version.
.. versionadded:: 1.0
Scriptable: Yes
"""
actual_version = "1.0.0"
if Utility.compare_versions(version, actual_vers... |
Return the library object. | def library(self) -> Library:
"""Return the library object.
.. versionadded:: 1.0
Scriptable: Yes
"""
assert self.__app.document_model
return Library(self.__app.document_model) |
Create a cost matrix from a profit matrix by calling inversion_function to invert each value. The inversion function must take one numeric argument ( of any type ) and return another numeric argument which is presumed to be the cost inverse of the original profit. | def make_cost_matrix(profit_matrix, inversion_function):
"""
Create a cost matrix from a profit matrix by calling
'inversion_function' to invert each value. The inversion
function must take one numeric argument (of any type) and return
another numeric argument which is presumed to be the cost invers... |
Convenience function: Displays the contents of a matrix of integers. | def print_matrix(matrix, msg=None):
"""
Convenience function: Displays the contents of a matrix of integers.
:Parameters:
matrix : list of lists
Matrix to print
msg : str
Optional message to print before displaying the matrix
"""
import math
if msg is n... |
Pad a possibly non - square matrix to make it square. | def pad_matrix(self, matrix, pad_value=0):
"""
Pad a possibly non-square matrix to make it square.
:Parameters:
matrix : list of lists
matrix to pad
pad_value : int
value to use to pad the matrix
:rtype: list of lists
:re... |
Compute the indexes for the lowest - cost pairings between rows and columns in the database. Returns a list of ( row column ) tuples that can be used to traverse the matrix. | def compute(self, cost_matrix):
"""
Compute the indexes for the lowest-cost pairings between rows and
columns in the database. Returns a list of (row, column) tuples
that can be used to traverse the matrix.
:Parameters:
cost_matrix : list of lists
The... |
Create an * n * x * n * matrix populating it with the specific value. | def __make_matrix(self, n, val):
"""Create an *n*x*n* matrix, populating it with the specific value."""
matrix = []
for i in range(n):
matrix += [[val for j in range(n)]]
return matrix |
For each row of the matrix find the smallest element and subtract it from every element in its row. Go to Step 2. | def __step1(self):
"""
For each row of the matrix, find the smallest element and
subtract it from every element in its row. Go to Step 2.
"""
C = self.C
n = self.n
for i in range(n):
minval = min(self.C[i])
# Find the minimum value for this... |
Find a zero ( Z ) in the resulting matrix. If there is no starred zero in its row or column star Z. Repeat for each element in the matrix. Go to Step 3. | def __step2(self):
"""
Find a zero (Z) in the resulting matrix. If there is no starred
zero in its row or column, star Z. Repeat for each element in the
matrix. Go to Step 3.
"""
n = self.n
for i in range(n):
for j in range(n):
if (self... |
Cover each column containing a starred zero. If K columns are covered the starred zeros describe a complete set of unique assignments. In this case Go to DONE otherwise Go to Step 4. | def __step3(self):
"""
Cover each column containing a starred zero. If K columns are
covered, the starred zeros describe a complete set of unique
assignments. In this case, Go to DONE, otherwise, Go to Step 4.
"""
n = self.n
count = 0
for i in range(n):
... |
Find a noncovered zero and prime it. If there is no starred zero in the row containing this primed zero Go to Step 5. Otherwise cover this row and uncover the column containing the starred zero. Continue in this manner until there are no uncovered zeros left. Save the smallest uncovered value and Go to Step 6. | def __step4(self):
"""
Find a noncovered zero and prime it. If there is no starred zero
in the row containing this primed zero, Go to Step 5. Otherwise,
cover this row and uncover the column containing the starred
zero. Continue in this manner until there are no uncovered zeros
... |
Construct a series of alternating primed and starred zeros as follows. Let Z0 represent the uncovered primed zero found in Step 4. Let Z1 denote the starred zero in the column of Z0 ( if any ). Let Z2 denote the primed zero in the row of Z1 ( there will always be one ). Continue until the series terminates at a primed ... | def __step5(self):
"""
Construct a series of alternating primed and starred zeros as
follows. Let Z0 represent the uncovered primed zero found in Step 4.
Let Z1 denote the starred zero in the column of Z0 (if any).
Let Z2 denote the primed zero in the row of Z1 (there will always... |
Add the value found in Step 4 to every element of each covered row and subtract it from every element of each uncovered column. Return to Step 4 without altering any stars primes or covered lines. | def __step6(self):
"""
Add the value found in Step 4 to every element of each covered
row, and subtract it from every element of each uncovered column.
Return to Step 4 without altering any stars, primes, or covered
lines.
"""
minval = self.__find_smallest()
... |
Find the smallest uncovered value in the matrix. | def __find_smallest(self):
"""Find the smallest uncovered value in the matrix."""
minval = sys.maxsize
for i in range(self.n):
for j in range(self.n):
if (not self.row_covered[i]) and (not self.col_covered[j]):
if minval > self.C[i][j]:
... |
Find the first uncovered element with value 0 | def __find_a_zero(self):
"""Find the first uncovered element with value 0"""
row = -1
col = -1
i = 0
n = self.n
done = False
while not done:
j = 0
while True:
if (self.C[i][j] == 0) and \
(not self.r... |
Find the first starred element in the specified row. Returns the column index or - 1 if no starred element was found. | def __find_star_in_row(self, row):
"""
Find the first starred element in the specified row. Returns
the column index, or -1 if no starred element was found.
"""
col = -1
for j in range(self.n):
if self.marked[row][j] == 1:
col = j
... |
Find the first starred element in the specified row. Returns the row index or - 1 if no starred element was found. | def __find_star_in_col(self, col):
"""
Find the first starred element in the specified row. Returns
the row index, or -1 if no starred element was found.
"""
row = -1
for i in range(self.n):
if self.marked[i][col] == 1:
row = i
... |
Find the first prime element in the specified row. Returns the column index or - 1 if no starred element was found. | def __find_prime_in_row(self, row):
"""
Find the first prime element in the specified row. Returns
the column index, or -1 if no starred element was found.
"""
col = -1
for j in range(self.n):
if self.marked[row][j] == 2:
col = j
... |
Clear all covered matrix cells | def __clear_covers(self):
"""Clear all covered matrix cells"""
for i in range(self.n):
self.row_covered[i] = False
self.col_covered[i] = False |
Erase all prime markings | def __erase_primes(self):
"""Erase all prime markings"""
for i in range(self.n):
for j in range(self.n):
if self.marked[i][j] == 2:
self.marked[i][j] = 0 |
Update contingency table with new values without creating a new object. | def update(self, a, b, c, d):
"""
Update contingency table with new values without creating a new object.
"""
self.table.ravel()[:] = [a, b, c, d]
self.N = self.table.sum() |
Frequency Bias. Formula: ( a + b )/ ( a + c ) | def bias(self):
"""
Frequency Bias.
Formula: (a+b)/(a+c)"""
return (self.table[0, 0] + self.table[0, 1]) / (self.table[0, 0] + self.table[1, 0]) |
Gilbert s Score or Threat Score or Critical Success Index a/ ( a + b + c ) | def csi(self):
"""Gilbert's Score or Threat Score or Critical Success Index a/(a+b+c)"""
return self.table[0, 0] / (self.table[0, 0] + self.table[0, 1] + self.table[1, 0]) |
Equitable Threat Score Gilbert Skill Score v ( a - R )/ ( a + b + c - R ) R = ( a + b ) ( a + c )/ N | def ets(self):
"""Equitable Threat Score, Gilbert Skill Score, v, (a - R)/(a + b + c - R), R=(a+b)(a+c)/N"""
r = (self.table[0, 0] + self.table[0, 1]) * (self.table[0, 0] + self.table[1, 0]) / self.N
return (self.table[0, 0] - r) / (self.table[0, 0] + self.table[0, 1] + self.table[1, 0] - r) |
Doolittle ( Heidke ) Skill Score. 2 ( ad - bc )/ (( a + b ) ( b + d ) + ( a + c ) ( c + d )) | def hss(self):
"""Doolittle (Heidke) Skill Score. 2(ad-bc)/((a+b)(b+d) + (a+c)(c+d))"""
return 2 * (self.table[0, 0] * self.table[1, 1] - self.table[0, 1] * self.table[1, 0]) / (
(self.table[0, 0] + self.table[0, 1]) * (self.table[0, 1] + self.table[1, 1]) +
(self.table[0, 0] + ... |
Peirce ( Hansen - Kuipers True ) Skill Score ( ad - bc )/ (( a + c ) ( b + d )) | def pss(self):
"""Peirce (Hansen-Kuipers, True) Skill Score (ad - bc)/((a+c)(b+d))"""
return (self.table[0, 0] * self.table[1, 1] - self.table[0, 1] * self.table[1, 0]) / \
((self.table[0, 0] + self.table[1, 0]) * (self.table[0, 1] + self.table[1, 1])) |
Clayton Skill Score ( ad - bc )/ (( a + b ) ( c + d )) | def css(self):
"""Clayton Skill Score (ad - bc)/((a+b)(c+d))"""
return (self.table[0, 0] * self.table[1, 1] - self.table[0, 1] * self.table[1, 0]) / \
((self.table[0, 0] + self.table[0, 1]) * (self.table[1, 0] + self.table[1, 1])) |
Load scikit - learn decision tree ensemble object from file. Parameters ---------- filename: str Name of the pickle file containing the tree object. Returns ------- tree ensemble object | def load_tree_object(filename):
"""
Load scikit-learn decision tree ensemble object from file.
Parameters
----------
filename : str
Name of the pickle file containing the tree object.
Returns
-------
tree ensemble object
"""
with open(filename) as file_obj:
... |
Write each decision tree in an ensemble to a file. | def output_tree_ensemble(tree_ensemble_obj, output_filename, attribute_names=None):
"""
Write each decision tree in an ensemble to a file.
Parameters
----------
tree_ensemble_obj : sklearn.ensemble object
Random Forest or Gradient Boosted Regression object
output_filename : str
... |
Recursively writes a string representation of a decision tree object. | def print_tree_recursive(tree_obj, node_index, attribute_names=None):
"""
Recursively writes a string representation of a decision tree object.
Parameters
----------
tree_obj : sklearn.tree._tree.Tree object
A base decision tree object
node_index : int
Index of the node being pr... |
Computes the mask used to create the training and validation set | def set_classifier_mask(self, v, base_mask=True):
"""Computes the mask used to create the training and validation set"""
base = self._base
v = tonparray(v)
a = np.unique(v)
if a[0] != -1 or a[1] != 1:
raise RuntimeError("The labels must be -1 and 1 (%s)" % a)
... |
Computes the mask used to create the training and validation set | def set_regression_mask(self, v):
"""Computes the mask used to create the training and validation set"""
base = self._base
index = np.arange(v.size())
np.random.shuffle(index)
ones = np.ones(v.size())
ones[index[int(base._tr_fraction * v.size()):]] = 0
base._mask ... |
Fitness function in the training set | def fitness(self, v):
"Fitness function in the training set"
base = self._base
if base._classifier:
if base._multiple_outputs:
hy = SparseArray.argmax(v.hy)
fit_func = base._fitness_function
if fit_func == 'macro-F1' or fit_func == 'a_F... |
Fitness function in the validation set In classification it uses BER and RSE in regression | def fitness_vs(self, v):
"""Fitness function in the validation set
In classification it uses BER and RSE in regression"""
base = self._base
if base._classifier:
if base._multiple_outputs:
v.fitness_vs = v._error
# if base._fitness_function == '... |
Set the fitness to a new node. Returns false in case fitness is not finite | def set_fitness(self, v):
"""Set the fitness to a new node.
Returns false in case fitness is not finite"""
base = self._base
self.fitness(v)
if not np.isfinite(v.fitness):
self.del_error(v)
return False
if base._tr_fraction < 1:
self.fi... |
Constrói uma: class: RespostaCancelarUltimaVenda a partir do retorno informado. | def analisar(retorno):
"""Constrói uma :class:`RespostaCancelarUltimaVenda` a partir do
retorno informado.
:param unicode retorno: Retorno da função ``CancelarUltimaVenda``.
"""
resposta = analisar_retorno(forcar_unicode(retorno),
funcao='EnviarDadosVenda',
... |
Convert a data element to xdata. No data copying occurs. | def convert_data_element_to_data_and_metadata_1(data_element) -> DataAndMetadata.DataAndMetadata:
"""Convert a data element to xdata. No data copying occurs.
The data element can have the following keys:
data (required)
is_sequence, collection_dimension_count, datum_dimension_count (optional de... |
Segment forecast tracks to only output data contined within a region in the CONUS as defined by the mapfile. | def output_sector_csv(self,csv_path,file_dict_key,out_path):
"""
Segment forecast tracks to only output data contined within a
region in the CONUS, as defined by the mapfile.
Args:
csv_path(str): Path to the full CONUS csv file.
file_dict_key(str): Dictionary ke... |
Segment patches of forecast tracks to only output data contined within a region in the CONUS as defined by the mapfile. | def output_sector_netcdf(self,netcdf_path,out_path,patch_radius,config):
"""
Segment patches of forecast tracks to only output data contined within a
region in the CONUS, as defined by the mapfile.
Args:
netcdf_path (str): Path to the full CONUS netcdf patch file.
... |
Return a json - clean dict. Will log info message for failures. | def clean_dict(d0, clean_item_fn=None):
"""
Return a json-clean dict. Will log info message for failures.
"""
clean_item_fn = clean_item_fn if clean_item_fn else clean_item
d = dict()
for key in d0:
cleaned_item = clean_item_fn(d0[key])
if cleaned_item is not None:
... |
Return a json - clean list. Will log info message for failures. | def clean_list(l0, clean_item_fn=None):
"""
Return a json-clean list. Will log info message for failures.
"""
clean_item_fn = clean_item_fn if clean_item_fn else clean_item
l = list()
for index, item in enumerate(l0):
cleaned_item = clean_item_fn(item)
l.append(cleaned_item)
... |
Return a json - clean tuple. Will log info message for failures. | def clean_tuple(t0, clean_item_fn=None):
"""
Return a json-clean tuple. Will log info message for failures.
"""
clean_item_fn = clean_item_fn if clean_item_fn else clean_item
l = list()
for index, item in enumerate(t0):
cleaned_item = clean_item_fn(item)
l.append(cleaned_item... |
Return a json - clean item or None. Will log info message for failure. | def clean_item(i):
"""
Return a json-clean item or None. Will log info message for failure.
"""
itype = type(i)
if itype == dict:
return clean_dict(i)
elif itype == list:
return clean_list(i)
elif itype == tuple:
return clean_tuple(i)
elif itype == numpy.float... |
Return a json - clean item or None. Will log info message for failure. | def clean_item_no_list(i):
"""
Return a json-clean item or None. Will log info message for failure.
"""
itype = type(i)
if itype == dict:
return clean_dict(i, clean_item_no_list)
elif itype == list:
return clean_tuple(i, clean_item_no_list)
elif itype == tuple:
re... |
Sample the stack in a thread and print it at regular intervals. | def sample_stack_all(count=10, interval=0.1):
"""Sample the stack in a thread and print it at regular intervals."""
def print_stack_all(l, ll):
l1 = list()
l1.append("*** STACKTRACE - START ***")
code = []
for threadId, stack in sys._current_frames().items():
sub_cod... |
Decision function i. e. the raw data of the prediction | def decision_function(self, X):
"Decision function i.e. the raw data of the prediction"
self._X = Model.convert_features(X)
self._eval()
return self._ind[0].hy |
Evaluates a individual using recursion and self. _pos as pointer | def _eval(self):
"Evaluates a individual using recursion and self._pos as pointer"
pos = self._pos
self._pos += 1
node = self._ind[pos]
if isinstance(node, Function):
args = [self._eval() for x in range(node.nargs)]
node.eval(args)
for x in arg... |
Random individual using full method | def create_random_ind_full(self, depth=0):
"Random individual using full method"
lst = []
self._create_random_ind_full(depth=depth, output=lst)
return lst |
Select either function or terminal in grow method | def grow_use_function(self, depth=0):
"Select either function or terminal in grow method"
if depth == 0:
return False
if depth == self._depth:
return True
return np.random.random() < 0.5 |
Random individual using grow method | def create_random_ind_grow(self, depth=0):
"Random individual using grow method"
lst = []
self._depth = depth
self._create_random_ind_grow(depth=depth, output=lst)
return lst |
Creates random population using ramped half - and - half method | def create_population(self, popsize=1000, min_depth=2,
max_depth=4,
X=None):
"Creates random population using ramped half-and-half method"
import itertools
args = [x for x in itertools.product(range(min_depth,
... |
Decision function i. e. the raw data of the prediction | def decision_function(self, X, **kwargs):
"Decision function i.e. the raw data of the prediction"
if X is None:
return self._hy_test
X = self.convert_features(X)
if len(X) < self.nvar:
_ = 'Number of variables differ, trained with %s given %s' % (self.nvar, len(X)... |
Median Fitness in the validation set | def fitness_vs(self):
"Median Fitness in the validation set"
l = [x.fitness_vs for x in self.models]
return np.median(l) |
Directory to store the graphviz models | def graphviz(self, directory, **kwargs):
"Directory to store the graphviz models"
import os
if not os.path.isdir(directory):
os.mkdir(directory)
output = os.path.join(directory, 'evodag-%s')
for k, m in enumerate(self.models):
m.graphviz(output % k, **kwar... |
Args: num_samples: Number of random samples at each grid point percentiles: Which percentiles to extract from the random samples | def load_data(self, num_samples=1000, percentiles=None):
"""
Args:
num_samples: Number of random samples at each grid point
percentiles: Which percentiles to extract from the random samples
Returns:
"""
self.percentiles = percentiles
self.num_samp... |
Calculate a probability based on the number of grid points in an area that exceed a threshold. | def neighborhood_probability(self, threshold, radius):
"""
Calculate a probability based on the number of grid points in an area that exceed a threshold.
Args:
threshold:
radius:
Returns:
"""
weights = disk(radius, dtype=np.uint8)
thresh... |
Encodes member percentile data to GRIB2 format. | def encode_grib2_percentile(self):
"""
Encodes member percentile data to GRIB2 format.
Returns:
Series of GRIB2 messages
"""
lscale = 1e6
grib_id_start = [7, 0, 14, 14, 2]
gdsinfo = np.array([0, np.product(self.data.shape[-2:]), 0, 0, 30], dtype=np.in... |
Encodes member percentile data to GRIB2 format. | def encode_grib2_data(self):
"""
Encodes member percentile data to GRIB2 format.
Returns:
Series of GRIB2 messages
"""
lscale = 1e6
grib_id_start = [7, 0, 14, 14, 2]
gdsinfo = np.array([0, np.product(self.data.shape[-2:]), 0, 0, 30], dtype=np.int32)
... |
Loads data from each ensemble member. | def load_data(self):
"""
Loads data from each ensemble member.
"""
for m, member in enumerate(self.members):
mo = ModelOutput(self.ensemble_name, member, self.run_date, self.variable,
self.start_date, self.end_date, self.path, self.map_file, self.... |
Calculate grid - point statistics across ensemble members. | def point_consensus(self, consensus_type):
"""
Calculate grid-point statistics across ensemble members.
Args:
consensus_type: mean, std, median, max, or percentile_nn
Returns:
EnsembleConsensus containing point statistic
"""
if "mean" in consensu... |
Determine the probability of exceeding a threshold at a grid point based on the ensemble forecasts at that point. | def point_probability(self, threshold):
"""
Determine the probability of exceeding a threshold at a grid point based on the ensemble forecasts at
that point.
Args:
threshold: If >= threshold assigns a 1 to member, otherwise 0.
Returns:
EnsembleConsensus
... |
Hourly probability of exceeding a threshold based on model values within a specified radius of a point. | def neighborhood_probability(self, threshold, radius, sigmas=None):
"""
Hourly probability of exceeding a threshold based on model values within a specified radius of a point.
Args:
threshold (float): probability of exceeding this threshold
radius (int): distance from po... |
Calculates the neighborhood probability of exceeding a threshold at any time over the period loaded. | def period_max_neighborhood_probability(self, threshold, radius, sigmas=None):
"""
Calculates the neighborhood probability of exceeding a threshold at any time over the period loaded.
Args:
threshold (float): splitting threshold for probability calculatations
radius (int... |
Reads the track forecasts and converts them to grid point values based on random sampling. | def load_data(self, grid_method="gamma", num_samples=1000, condition_threshold=0.5, zero_inflate=False,
percentile=None):
"""
Reads the track forecasts and converts them to grid point values based on random sampling.
Args:
grid_method: "gamma" by default
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.