INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. cancelar_ultima_venda.
def cancelar_ultima_venda(self, chave_cfe, dados_cancelamento): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.cancelar_ultima_venda`. :return: Uma resposta SAT especializada em ``CancelarUltimaVenda``. :rtype: satcfe.resposta.cancelarultimavenda.RespostaCancelarUltimaVenda """ reto...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. consultar_sat.
def consultar_sat(self): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.consultar_sat`. :return: Uma resposta SAT padrão. :rtype: satcfe.resposta.padrao.RespostaSAT """ retorno = super(ClienteSATLocal, self).consultar_sat() return RespostaSAT.consultar_sat(retorno)
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. consultar_status_operacional.
def consultar_status_operacional(self): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.consultar_status_operacional`. :return: Uma resposta SAT especializada em ``ConsultarStatusOperacional``. :rtype: satcfe.resposta.consultarstatusoperacional.RespostaConsultarStatusOperacional """ ...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. consultar_numero_sessao.
def consultar_numero_sessao(self, numero_sessao): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.consultar_numero_sessao`. :return: Uma resposta SAT que irá depender da sessão consultada. :rtype: satcfe.resposta.padrao.RespostaSAT """ retorno = super(ClienteSATLocal, self).\ ...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. configurar_interface_de_rede.
def configurar_interface_de_rede(self, configuracao): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.configurar_interface_de_rede`. :return: Uma resposta SAT padrão. :rtype: satcfe.resposta.padrao.RespostaSAT """ retorno = super(ClienteSATLocal, self).\ configurar_in...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. associar_assinatura.
def associar_assinatura(self, sequencia_cnpj, assinatura_ac): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.associar_assinatura`. :return: Uma resposta SAT padrão. :rtype: satcfe.resposta.padrao.RespostaSAT """ retorno = super(ClienteSATLocal, self).\ associar_assin...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. atualizar_software_sat.
def atualizar_software_sat(self): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.atualizar_software_sat`. :return: Uma resposta SAT padrão. :rtype: satcfe.resposta.padrao.RespostaSAT """ retorno = super(ClienteSATLocal, self).atualizar_software_sat() return RespostaSAT.atual...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. extrair_logs.
def extrair_logs(self): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.extrair_logs`. :return: Uma resposta SAT especializada em ``ExtrairLogs``. :rtype: satcfe.resposta.extrairlogs.RespostaExtrairLogs """ retorno = super(ClienteSATLocal, self).extrair_logs() return Resposta...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. bloquear_sat.
def bloquear_sat(self): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.bloquear_sat`. :return: Uma resposta SAT padrão. :rtype: satcfe.resposta.padrao.RespostaSAT """ retorno = super(ClienteSATLocal, self).bloquear_sat() return RespostaSAT.bloquear_sat(retorno)
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. desbloquear_sat.
def desbloquear_sat(self): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.desbloquear_sat`. :return: Uma resposta SAT padrão. :rtype: satcfe.resposta.padrao.RespostaSAT """ retorno = super(ClienteSATLocal, self).desbloquear_sat() return RespostaSAT.desbloquear_sat(retorno)
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. trocar_codigo_de_ativacao.
def trocar_codigo_de_ativacao(self, novo_codigo_ativacao, opcao=constantes.CODIGO_ATIVACAO_REGULAR, codigo_emergencia=None): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.trocar_codigo_de_ativacao`. :return: Uma resposta SAT padrão. :rtype: satcfe.resposta.padrao.RespostaSA...
Resulta no documento XML como string que pode ou não incluir a declaração XML no início do documento.
def documento(self, *args, **kwargs): """Resulta no documento XML como string, que pode ou não incluir a declaração XML no início do documento. """ forcar_unicode = kwargs.pop('forcar_unicode', False) incluir_xml_decl = kwargs.pop('incluir_xml_decl', True) doc = ET.tostri...
Start the application.
def start(self, skip_choose=False, fixed_workspace_dir=None): """ Start the application. Looks for workspace_location persistent string. If it doesn't find it, uses a default workspace location. Then checks to see if that workspace exists. If not and if skip_cho...
A sort key to for the created field of a data item. The sort by uuid makes it determinate.
def sort_by_date_key(data_item): """ A sort key to for the created field of a data item. The sort by uuid makes it determinate. """ return data_item.title + str(data_item.uuid) if data_item.is_live else str(), data_item.date_for_sorting, str(data_item.uuid)
Return a new library item which is a copy of this one with any dynamic behavior made static.
def snapshot(self): """Return a new library item which is a copy of this one with any dynamic behavior made static.""" data_item = self.__class__() # data format (temporary until moved to buffered data source) data_item.large_format = self.large_format data_item.set_data_and_meta...
Used to signal changes to the ref var which are kept in document controller. ugh.
def set_r_value(self, r_var: str, *, notify_changed=True) -> None: """Used to signal changes to the ref var, which are kept in document controller. ugh.""" self.r_var = r_var self._description_changed() if notify_changed: # set to False to set the r-value at startup; avoid marking it as...
Sets the underlying data and data - metadata to the data_and_metadata.
def set_data_and_metadata(self, data_and_metadata, data_modified=None): """Sets the underlying data and data-metadata to the data_and_metadata. Note: this does not make a copy of the data. """ self.increment_data_ref_count() try: if data_and_metadata: ...
Return the color map data as a uint8 ndarray with shape ( 256 3 ).
def color_map_data(self) -> typing.Optional[numpy.ndarray]: """Return the color map data as a uint8 ndarray with shape (256, 3).""" if self.display_data_shape is None: # is there display data? return None else: return self.__color_map_data if self.__color_map_data is not...
Return the display values.
def get_calculated_display_values(self, immediate: bool=False) -> DisplayValues: """Return the display values. Return the current (possibly uncalculated) display values unless 'immediate' is specified. If 'immediate', return the existing (calculated) values if they exist. Using the 'immediate'...
Increment display reference count to indicate this library item is currently displayed.
def increment_display_ref_count(self, amount: int=1): """Increment display reference count to indicate this library item is currently displayed.""" display_ref_count = self.__display_ref_count self.__display_ref_count += amount if display_ref_count == 0: self.__is_master = Tr...
Decrement display reference count to indicate this library item is no longer displayed.
def decrement_display_ref_count(self, amount: int=1): """Decrement display reference count to indicate this library item is no longer displayed.""" assert not self._closed self.__display_ref_count -= amount if self.__display_ref_count == 0: self.__is_master = False if...
Calculate best display limits and set them.
def auto_display_limits(self): """Calculate best display limits and set them.""" display_data_and_metadata = self.get_calculated_display_values(True).display_data_and_metadata data = display_data_and_metadata.data if display_data_and_metadata else None if data is not None: # ...
Return a new library item which is a copy of this one with any dynamic behavior made static.
def snapshot(self): """Return a new library item which is a copy of this one with any dynamic behavior made static.""" display_item = self.__class__() display_item.display_type = self.display_type # metadata display_item._set_persistent_property_value("title", self._get_persisten...
Increment display reference count to indicate this library item is currently displayed.
def increment_display_ref_count(self, amount: int=1): """Increment display reference count to indicate this library item is currently displayed.""" display_ref_count = self.__display_ref_count self.__display_ref_count += amount for display_data_channel in self.display_data_channels: ...
Decrement display reference count to indicate this library item is no longer displayed.
def decrement_display_ref_count(self, amount: int=1): """Decrement display reference count to indicate this library item is no longer displayed.""" assert not self._closed self.__display_ref_count -= amount for display_data_channel in self.display_data_channels: display_data_...
Remove a graphic but do it through the container so dependencies can be tracked.
def remove_graphic(self, graphic: Graphics.Graphic, *, safe: bool=False) -> typing.Optional[typing.Sequence]: """Remove a graphic, but do it through the container, so dependencies can be tracked.""" return self.remove_model_item(self, "graphics", graphic, safe=safe)
Shape of the underlying data if only one.
def dimensional_shape(self) -> typing.Optional[typing.Tuple[int, ...]]: """Shape of the underlying data, if only one.""" if not self.__data_and_metadata: return None return self.__data_and_metadata.dimensional_shape
Change the view to encompass the channels and data represented by the given intervals.
def view_to_intervals(self, data_and_metadata: DataAndMetadata.DataAndMetadata, intervals: typing.List[typing.Tuple[float, float]]) -> None: """Change the view to encompass the channels and data represented by the given intervals.""" left = None right = None for interval in intervals: ...
Writes a zip file local file header structure at the current file position.
def write_local_file(fp, name_bytes, writer, dt): """ Writes a zip file local file header structure at the current file position. Returns data_len, crc32 for the data. :param fp: the file point to which to write the header :param name: the name of the file :param writer: a ...
Write a zip fie directory entry at the current file position
def write_directory_data(fp, offset, name_bytes, data_len, crc32, dt): """ Write a zip fie directory entry at the current file position :param fp: the file point to which to write the header :param offset: the offset of the associated local file header :param name: the name of the f...
Write zip file end of directory header at the current file position
def write_end_of_directory(fp, dir_size, dir_offset, count): """ Write zip file end of directory header at the current file position :param fp: the file point to which to write the header :param dir_size: the total size of the directory :param dir_offset: the start of the first dire...
Write custom zip file of data and properties to fp
def write_zip_fp(fp, data, properties, dir_data_list=None): """ Write custom zip file of data and properties to fp :param fp: the file point to which to write the header :param data: the data to write to the file; may be None :param properties: the properties to write to the file; m...
Write custom zip file to the file path
def write_zip(file_path, data, properties): """ Write custom zip file to the file path :param file_path: the file to which to write the zip file :param data: the data to write to the file; may be None :param properties: the properties to write to the file; may be None The p...
Parse the zip file headers at fp
def parse_zip(fp): """ Parse the zip file headers at fp :param fp: the file pointer from which to parse the zip file :return: A tuple of local files, directory headers, and end of central directory The local files are dictionary where the keys are the local file offset and the ...
Read a numpy data array from the zip file
def read_data(fp, local_files, dir_files, name_bytes): """ Read a numpy data array from the zip file :param fp: a file pointer :param local_files: the local files structure :param dir_files: the directory headers :param name: the name of the data file to read :return...
Read json properties from the zip file
def read_json(fp, local_files, dir_files, name_bytes): """ Read json properties from the zip file :param fp: a file pointer :param local_files: the local files structure :param dir_files: the directory headers :param name: the name of the json file to read :return: t...
Rewrite the json properties in the zip file
def rewrite_zip(file_path, properties): """ Rewrite the json properties in the zip file :param file_path: the file path to the zip file :param properties: the updated properties to write to the zip file This method will attempt to keep the data file within the zip file inta...
Return whether the given absolute file path is an ndata file.
def is_matching(cls, file_path): """ Return whether the given absolute file path is an ndata file. """ if file_path.endswith(".ndata") and os.path.exists(file_path): try: with open(file_path, "r+b") as fp: local_files, dir_files, eocd =...
Write data to the ndata file specified by reference.
def write_data(self, data, file_datetime): """ Write data to the ndata file specified by reference. :param data: the numpy array data to write :param file_datetime: the datetime for the file """ with self.__lock: assert data is not None ...
Write properties to the ndata file specified by reference.
def write_properties(self, properties, file_datetime): """ Write properties to the ndata file specified by reference. :param reference: the reference to which to write :param properties: the dict to write to the file :param file_datetime: the datetime for the fil...
Read properties from the ndata file reference
def read_properties(self): """ Read properties from the ndata file reference :param reference: the reference from which to read :return: a tuple of the item_uuid and a dict of the properties """ with self.__lock: absolute_file_path = self.__file_p...
Read data from the ndata file reference
def read_data(self): """ Read data from the ndata file reference :param reference: the reference from which to read :return: a numpy array of the data; maybe None """ with self.__lock: absolute_file_path = self.__file_path #logging.deb...
Remove the ndata file reference
def remove(self): """ Remove the ndata file reference :param reference: the reference to remove """ with self.__lock: absolute_file_path = self.__file_path #logging.debug("DELETE data file %s", absolute_file_path) if os.path.isfile(abs...
Build the dynamic menu for the selected display panel.
def build_menu(self, display_type_menu, document_controller, display_panel): """Build the dynamic menu for the selected display panel. The user accesses this menu by right-clicking on the display panel. The basic menu items are to an empty display panel or a browser display panel. Aft...
Override from PersistentObject.
def persistent_object_context_changed(self): """ Override from PersistentObject. """ super().persistent_object_context_changed() def source_registered(source): self.__source = source def source_unregistered(source=None): pass def reference_registered(pr...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. ativar_sat.
def ativar_sat(self, tipo_certificado, cnpj, codigo_uf): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.ativar_sat`. :return: Uma resposta SAT especializada em ``AtivarSAT``. :rtype: satcfe.resposta.ativarsat.RespostaAtivarSAT """ resp = self._http_post('ativarsat', ...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. comunicar_certificado_icpbrasil.
def comunicar_certificado_icpbrasil(self, certificado): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.comunicar_certificado_icpbrasil`. :return: Uma resposta SAT padrão. :rtype: satcfe.resposta.padrao.RespostaSAT """ resp = self._http_post('comunicarcertificadoicpbrasil', ...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. enviar_dados_venda.
def enviar_dados_venda(self, dados_venda): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.enviar_dados_venda`. :return: Uma resposta SAT especializada em ``EnviarDadosVenda``. :rtype: satcfe.resposta.enviardadosvenda.RespostaEnviarDadosVenda """ resp = self._http_post('enviardadosve...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. cancelar_ultima_venda.
def cancelar_ultima_venda(self, chave_cfe, dados_cancelamento): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.cancelar_ultima_venda`. :return: Uma resposta SAT especializada em ``CancelarUltimaVenda``. :rtype: satcfe.resposta.cancelarultimavenda.RespostaCancelarUltimaVenda """ resp...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. consultar_sat.
def consultar_sat(self): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.consultar_sat`. :return: Uma resposta SAT padrão. :rtype: satcfe.resposta.padrao.RespostaSAT """ resp = self._http_post('consultarsat') conteudo = resp.json() return RespostaSAT.consultar_sat(con...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. consultar_status_operacional.
def consultar_status_operacional(self): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.consultar_status_operacional`. :return: Uma resposta SAT especializada em ``ConsultarStatusOperacional``. :rtype: satcfe.resposta.consultarstatusoperacional.RespostaConsultarStatusOperacional """ ...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. consultar_numero_sessao.
def consultar_numero_sessao(self, numero_sessao): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.consultar_numero_sessao`. :return: Uma resposta SAT que irá depender da sessão consultada. :rtype: satcfe.resposta.padrao.RespostaSAT """ resp = self._http_post('consultarnumerosessao', ...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. configurar_interface_de_rede.
def configurar_interface_de_rede(self, configuracao): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.configurar_interface_de_rede`. :return: Uma resposta SAT padrão. :rtype: satcfe.resposta.padrao.RespostaSAT """ resp = self._http_post('configurarinterfacederede', co...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. associar_assinatura.
def associar_assinatura(self, sequencia_cnpj, assinatura_ac): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.associar_assinatura`. :return: Uma resposta SAT padrão. :rtype: satcfe.resposta.padrao.RespostaSAT """ resp = self._http_post('associarassinatura', sequencia_...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. atualizar_software_sat.
def atualizar_software_sat(self): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.atualizar_software_sat`. :return: Uma resposta SAT padrão. :rtype: satcfe.resposta.padrao.RespostaSAT """ resp = self._http_post('atualizarsoftwaresat') conteudo = resp.json() return Res...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. extrair_logs.
def extrair_logs(self): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.extrair_logs`. :return: Uma resposta SAT especializada em ``ExtrairLogs``. :rtype: satcfe.resposta.extrairlogs.RespostaExtrairLogs """ resp = self._http_post('extrairlogs') conteudo = resp.json() ...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. bloquear_sat.
def bloquear_sat(self): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.bloquear_sat`. :return: Uma resposta SAT padrão. :rtype: satcfe.resposta.padrao.RespostaSAT """ resp = self._http_post('bloquearsat') conteudo = resp.json() return RespostaSAT.bloquear_sat(conteud...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. desbloquear_sat.
def desbloquear_sat(self): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.desbloquear_sat`. :return: Uma resposta SAT padrão. :rtype: satcfe.resposta.padrao.RespostaSAT """ resp = self._http_post('desbloquearsat') conteudo = resp.json() return RespostaSAT.desbloquear...
Sobrepõe: meth: ~satcfe. base. FuncoesSAT. trocar_codigo_de_ativacao.
def trocar_codigo_de_ativacao(self, novo_codigo_ativacao, opcao=constantes.CODIGO_ATIVACAO_REGULAR, codigo_emergencia=None): """Sobrepõe :meth:`~satcfe.base.FuncoesSAT.trocar_codigo_de_ativacao`. :return: Uma resposta SAT padrão. :rtype: satcfe.resposta.padrao.RespostaSA...
Return the bounds property in relative coordinates.
def bounds(self) -> typing.Tuple[typing.Tuple[float, float], typing.Tuple[float, float]]: """Return the bounds property in relative coordinates. Bounds is a tuple ((top, left), (height, width))""" ...
Set the end property in relative coordinates.
def end(self, value: typing.Union[float, typing.Tuple[float, float]]) -> None: """Set the end property in relative coordinates. End may be a float when graphic is an Interval or a tuple (y, x) when graphic is a Line.""" ...
Set the end property in relative coordinates.
def start(self, value: typing.Union[float, typing.Tuple[float, float]]) -> None: """Set the end property in relative coordinates. End may be a float when graphic is an Interval or a tuple (y, x) when graphic is a Line.""" ...
Return the vector property in relative coordinates.
def vector(self) -> typing.Tuple[typing.Tuple[float, float], typing.Tuple[float, float]]: """Return the vector property in relative coordinates. Vector will be a tuple of tuples ((y_start, x_start), (y_end, x_end)).""" ...
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. ...
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 calibration object with offset scale and units.
def create_calibration(self, offset: float=None, scale: float=None, units: str=None) -> Calibration.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: The unit...
Create a data_and_metadata object from data.
def create_data_and_metadata(self, data: numpy.ndarray, intensity_calibration: Calibration.Calibration=None, dimensional_calibrations: typing.List[Calibration.Calibration]=None, metadata: dict=None, timestamp: str=None, data_descriptor: DataAndMetadata.DataDescriptor=None) -> DataAndMetadata.DataAndMetadata: ""...
Create a data_and_metadata object from data.
def create_data_and_metadata_from_data(self, data: numpy.ndarray, intensity_calibration: Calibration.Calibration=None, dimensional_calibrations: typing.List[Calibration.Calibration]=None, metadata: dict=None, timestamp: str=None) -> DataAndMetadata.DataAndMetadata: """Create a data_and_metadata object from data...
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...
Called when an item ( calibration_observable ) is inserted into the list widget. Returns a widget.
def make_calibration_row_widget(ui, calibration_observable, label: str=None): """Called when an item (calibration_observable) is inserted into the list widget. Returns a widget.""" calibration_row = ui.create_row_widget() row_label = ui.create_label_widget(label, properties={"width": 60}) row_label.widg...
Subclasses should call this to add content in the section s top level column.
def add_widget_to_content(self, widget): """Subclasses should call this to add content in the section's top level column.""" self.__section_content_column.add_spacing(4) self.__section_content_column.add(widget)
Called when an item ( calibration_observable ) is inserted into the list widget. Returns a widget.
def __create_list_item_widget(self, ui, calibration_observable): """Called when an item (calibration_observable) is inserted into the list widget. Returns a widget.""" calibration_row = make_calibration_row_widget(ui, calibration_observable) column = ui.create_column_widget() column.add_...
Repaint the canvas item. This will occur on a thread.
def _repaint(self, drawing_context): """Repaint the canvas item. This will occur on a thread.""" # canvas size canvas_width = self.canvas_size[1] canvas_height = self.canvas_size[0] left = self.display_limits[0] right = self.display_limits[1] # draw left displa...
Repaint the canvas item. This will occur on a thread.
def _repaint(self, drawing_context): """Repaint the canvas item. This will occur on a thread.""" # canvas size canvas_width = self.canvas_size[1] canvas_height = self.canvas_size[0] # draw background if self.background_color: with drawing_context.saver(): ...
Set the data and mark the canvas item for updating.
def color_map_data(self, data: numpy.ndarray) -> None: """Set the data and mark the canvas item for updating. Data should be an ndarray of shape (256, 3) with type uint8 """ self.__color_map_data = data self.update()
Repaint the canvas item. This will occur on a thread.
def _repaint(self, drawing_context: DrawingContext.DrawingContext): """Repaint the canvas item. This will occur on a thread.""" # canvas size canvas_width = self.canvas_size.width canvas_height = self.canvas_size.height with drawing_context.saver(): if self.__color_...
Parameters used to initialize the class
def get_params(self): "Parameters used to initialize the class" import inspect a = inspect.getargspec(self.__init__)[0] out = dict() for key in a[1:]: value = getattr(self, "_%s" % key, None) out[key] = value return out
Instance file name
def signature(self): "Instance file name" kw = self.get_params() keys = sorted(kw.keys()) l = [] for k in keys: n = k[0] + k[-1] v = kw[k] if k == 'function_set': v = "_".join([x.__name__[0] + x.__n...
Class containing the population and all the individuals generated
def population(self): "Class containing the population and all the individuals generated" try: return self._p except AttributeError: self._p = self._population_class(base=self, tournament_size=self._tournament_size, ...
Returns a random variable with the associated weight
def random_leaf(self): "Returns a random variable with the associated weight" for i in range(self._number_tries_feasible_ind): var = np.random.randint(self.nvar) v = self._random_leaf(var) if v is None: continue return v raise Runti...
Returns an offspring with the associated weight ( s )
def random_offspring(self): "Returns an offspring with the associated weight(s)" function_set = self.function_set function_selection = self._function_selection_ins function_selection.density = self.population.density function_selection.unfeasible_functions.clear() for i i...
Test whether the stopping criteria has been achieved.
def stopping_criteria(self): "Test whether the stopping criteria has been achieved." if self.stopping_criteria_tl(): return True if self.generations < np.inf: inds = self.popsize * self.generations flag = inds <= len(self.population.hist) else: ...
Number of classes of v also sets the labes
def nclasses(self, v): "Number of classes of v, also sets the labes" if not self.classifier: return 0 if isinstance(v, list): self._labels = np.arange(len(v)) return if not isinstance(v, np.ndarray): v = tonparray(v) self._labels = ...
Evolutive process
def fit(self, X, y, test_set=None): """Evolutive process""" self._init_time = time.time() self.X = X if self._popsize == "nvar": self._popsize = self.nvar + len(self._input_functions) if isinstance(test_set, str) and test_set == 'shuffle': test_set = self....
Decision function i. e. the raw data of the prediction
def decision_function(self, v=None, X=None): "Decision function i.e. the raw data of the prediction" m = self.model(v=v) return m.decision_function(X)
In classification this returns the classes in regression it is equivalent to the decision function
def predict(self, v=None, X=None): """In classification this returns the classes, in regression it is equivalent to the decision function""" if X is None: X = v v = None m = self.model(v=v) return m.predict(X)
Gevent - based WSGI - HTTP server.
def serve(application, host='127.0.0.1', port=8080): """Gevent-based WSGI-HTTP server.""" # Instantiate the server with a host/port configuration and our application. WSGIServer((host, int(port)), application).serve_forever()
Returns the subscribers for a given object.
def get_subscribers(obj): """ Returns the subscribers for a given object. :param obj: Any object. """ ctype = ContentType.objects.get_for_model(obj) return Subscription.objects.filter(content_type=ctype, object_id=obj.pk)
Returns True if the user is subscribed to the given object.
def is_subscribed(user, obj): """ Returns ``True`` if the user is subscribed to the given object. :param user: A ``User`` instance. :param obj: Any object. """ if not user.is_authenticated(): return False ctype = ContentType.objects.get_for_model(obj) try: Subscriptio...
Create a new subclass of Context which incorporates instance attributes and new descriptors. This promotes an instance and its instance attributes up to being a class with class attributes then returns an instance of that class.
def _promote(self, name, instantiate=True): """Create a new subclass of Context which incorporates instance attributes and new descriptors. This promotes an instance and its instance attributes up to being a class with class attributes, then returns an instance of that class. """ metaclass = type(self._...
Run an individual simulation.
def run_individual(sim_var, reference, neuroml_file, nml_doc, still_included, generate_dir, target, sim_time, dt, simulator, cl...
Run simulation for each candidate This run method will loop through each candidate and run the simulation corresponding to its parameter values. It will populate an array called traces with the resulting voltage traces for the simulation and return it.
def run(self,candidates,parameters): """ Run simulation for each candidate This run method will loop through each candidate and run the simulation corresponding to its parameter values. It will populate an array called traces with the resulting voltage traces for the sim...
Executed prior to processing a request.
def prepare(self, context): """Executed prior to processing a request.""" if __debug__: log.debug("Assigning thread local request context.") self.local.context = context
Register a handler for a given type class interface or abstract base class. View registration should happen within the start callback of an extension. For example to register the previous json view example: class JSONExtension: def start ( self context ): context. view. register ( tuple json ) The approach of explicitl...
def register(self, kind, handler): """Register a handler for a given type, class, interface, or abstract base class. View registration should happen within the `start` callback of an extension. For example, to register the previous `json` view example: class JSONExtension: def start(self, context): ...
Serve files from disk. This utility endpoint factory is meant primarily for use in development environments ; in production environments it is better ( more efficient secure etc. ) to serve your static content using a front end load balancer such as Nginx. The first argument base represents the base path to serve files...
def static(base, mapping=None, far=('js', 'css', 'gif', 'jpg', 'jpeg', 'png', 'ttf', 'woff')): """Serve files from disk. This utility endpoint factory is meant primarily for use in development environments; in production environments it is better (more efficient, secure, etc.) to serve your static content using a ...
Diesel - based ( greenlet ) WSGI - HTTP server. As a minor note this is crazy. Diesel includes Flask too.
def serve(application, host='127.0.0.1', port=8080): """Diesel-based (greenlet) WSGI-HTTP server. As a minor note, this is crazy. Diesel includes Flask, too. """ # Instantiate the server with a host/port configuration and our application. WSGIApplication(application, port=int(port), iface=host).run()
Parse command - line arguments.
def process_args(): """ Parse command-line arguments. """ parser = argparse.ArgumentParser(description="A script for plotting files containing spike time data") parser.add_argument('spiketimeFiles', type=str, metavar='<spiketime file>', ...
Python - standard WSGI - HTTP server for testing purposes. The additional work performed here is to match the default startup output of waitress. This is not a production quality interface and will be have badly under load.
def simple(application, host='127.0.0.1', port=8080): """Python-standard WSGI-HTTP server for testing purposes. The additional work performed here is to match the default startup output of "waitress". This is not a production quality interface and will be have badly under load. """ # Try to be handy as many ...
A specialized version of the reference WSGI - CGI server to adapt to Microsoft IIS quirks. This is not a production quality interface and will behave badly under load.
def iiscgi(application): """A specialized version of the reference WSGI-CGI server to adapt to Microsoft IIS quirks. This is not a production quality interface and will behave badly under load. """ try: from wsgiref.handlers import IISCGIHandler except ImportError: print("Python 3.2 or newer is required.") ...