Package input_widgets

This package contains the widgets for entering / selecting parameters for the filter design.

input_tab_widgets

Tabbed container for all input widgets

class pyfda.input_widgets.input_tab_widgets.InputTabWidgets(parent)[source]

Create a tabbed widget for all input subwidgets in the list fb.input_widgets_list. This list is compiled at startup in pyfda.tree_builder.Tree_Builder.

log_rx(dict_sig=None)[source]

Enable self.sig_rx.connect(self.log_rx) above for debugging.

input_specs

Widget stacking all subwidgets for filter specification and design. The actual filter design is started here as well.

class pyfda.input_widgets.input_specs.Input_Specs(parent)[source]

Build widget for entering all filter specs

load_dict()[source]

Reload all specs/parameters entries from global dict fb.fil[0], using the “load_dict” methods of the individual classes

process_sig_rx(dict_sig=None, propagate=False)[source]

Process signals coming in via subwidgets and sig_rx

All signals terminate here unless the flag propagate=True.

The sender name of signals coming in from local subwidgets is changed to its parent widget (input_specs) to prevent infinite loops.

process_sig_rx_local(dict_sig=None)[source]

Flag signals coming in from local subwidgets with propagate=True before proceeding with processing in process_sig_rx.

quit_program()[source]

When <QUIT> button is pressed, send ‘quit_program’

start_design_filt()[source]

Start the actual filter design process:

  • store the entries of all input widgets in the global filter dict.
  • call the design method, passing the whole dictionary as the argument: let the design method pick the needed specs
  • update the input widgets in case weights, corner frequencies etc. have been changed by the filter design method
  • the plots are updated via signal-slot connection
update_UI(dict_sig={})[source]

update_UI is called every time the filter design method or order (min / man) has been changed as this usually requires a different set of frequency and amplitude specs.

At this time, the actual filter object instance has been created from the name of the design method (e.g. ‘cheby1’) in select_filter.py. Its handle has been stored in fb.fil_inst.

fb.fil[0] (currently selected filter) is read, then general information for the selected filter type and order (min/man) is gathered from the filter tree [fb.fil_tree], i.e. which parameters are needed, which widgets are visible and which message shall be displayed.

Then, the UIs of all subwidgets are updated using their “update_UI” method.

pyfda.input_widgets.input_specs.classes = {'Input_Specs': 'Specs'}

display name

Type:Dict containing class name

select_filter

Subwidget for selecting the filter, consisting of combo boxes for: - Response Type (LP, HP, Hilbert, …) - Filter Type (IIR, FIR, CIC …) - Filter Class (Butterworth, …)

class pyfda.input_widgets.select_filter.SelectFilter(parent)[source]

Construct and read combo boxes for selecting the filter, consisting of the following hierarchy:

  1. Response Type rt (LP, HP, Hilbert, …)
  2. Filter Type ft (IIR, FIR, CIC …)
  3. Filter Class (Butterworth, …)

Every time a combo box is changed manually, the filter tree for the selected response resp. filter type is read and the combo box(es) further down in the hierarchy are populated according to the available combinations.

sig_tx({‘filt_changed’}) is emitted and propagated to input_filter_specs.py where it triggers the recreation of all subwidgets.

load_dict()[source]

Reload comboboxes from filter dictionary to update changed settings after loading a filter design from disk. load_dict uses the automatism of _set_response_type etc. of checking whether the previously selected filter design method is also available for the new combination.

load_filter_order(enb_signal=False)[source]
Called by set_design_method or from InputSpecs (with enb_signal = False),
load filter order setting from fb.fil[0] and update widgets

input_coeffs

Widget for displaying and modifying filter coefficients

class pyfda.input_widgets.input_coeffs.Input_Coeffs(parent)[source]

Create widget with a (sort of) model-view architecture for viewing / editing / entering data contained in self.ba which is a list of two numpy arrays:

  • self.ba[0] contains the numerator coefficients (“b”)
  • self.ba[1] contains the denominator coefficients (“a”)

The list don’t neccessarily have the same length but they are always defined. For FIR filters, self.ba[1][0] = 1, all other elements are zero.

The length of both lists can be egalized with self._equalize_ba_length().

Views / formats are handled by the ItemDelegate() class.

load_dict()[source]

Load all entries from filter dict fb.fil[0][‘ba’] into the coefficient list self.ba and update the display via self._refresh_table().

The filter dict is a “normal” 2D-numpy float array for the b and a coefficients while the coefficient register self.ba is a list of two float ndarrays to allow for different lengths of b and a subarrays while adding / deleting items.

process_sig_rx(dict_sig=None)[source]

Process signals coming from sig_rx

qdict2ui()[source]

Set the UI from the quantization dict and update the fixpoint object. When neither WI == 0 nor WF == 0, set the quantization format to general fractional format qfrac.

quant_coeffs()[source]

Quantize selected / all coefficients in self.ba and refresh QTableWidget

ui2qdict()[source]

Read out the settings of the quantization comboboxes.

  • Store them in the filter dict fb.fil[0][‘fxqc’][‘QCB’] and as class
    attributes in the fixpoint object self.myQ
  • Emit a signal with ‘view_changed’:’q_coeff’
  • Refresh the table
class pyfda.input_widgets.input_coeffs.ItemDelegate(parent)[source]

The following methods are subclassed to replace display and editor of the QTableWidget.

  • displayText() displays the data stored in the table in various number formats
  • createEditor() creates a line edit instance for editing table entries
  • setEditorData() pass data with full precision and in selected format to editor
  • setModelData() pass edited data back to model (self.ba)
createEditor(parent, options, index)[source]

Neet to set editor explicitly, otherwise QDoubleSpinBox instance is created when space is not sufficient?! editor: instance of e.g. QLineEdit (default) index: instance of QModelIndex options: instance of QStyleOptionViewItemV4

displayText(text, locale)[source]

Display text with selected fixpoint base and number of places

text: string / QVariant from QTableWidget to be rendered locale: locale for the text

The instance parameter myQ.ovr_flag is set to +1 or -1 for positive / negative overflows, else it is 0.

initStyleOption(option, index)[source]

Initialize option with the values using the index index. When the item (0,1) is processed, it is styled especially. All other items are passed to the original initStyleOption() which then calls displayText(). Afterwards, check whether an fixpoint overflow has occured and color item background accordingly.

setEditorData(editor, index)[source]

Pass the data to be edited to the editor: - retrieve data with full accuracy from self.ba (in float format) - requantize data according to settings in fixpoint object - represent it in the selected format (int, hex, …)

editor: instance of e.g. QLineEdit index: instance of QModelIndex

setModelData(editor, model, index)[source]

When editor has finished, read the updated data from the editor, convert it back to floating point format and store it in both the model (= QTableWidget) and in self.ba. Finally, refresh the table item to display it in the selected format (via float2frmt()).

editor: instance of e.g. QLineEdit model: instance of QAbstractTableModel index: instance of QModelIndex

text(item)[source]

Return item text as string transformed by self.displayText()

pyfda.input_widgets.input_coeffs.classes = {'Input_Coeffs': 'b,a'}

display name

Type:Dict containing class name

input_pz

Widget for displaying and modifying filter Poles and Zeros

class pyfda.input_widgets.input_pz.Input_PZ(parent)[source]

Create the window for entering exporting / importing and saving / loading data

cmplx2frmt(text, places=-1)[source]

Convert number “text” (real or complex or string) to the format defined by cmbPZFrmt.

Returns:string
eventFilter(source, event)[source]

Filter all events generated by the QLineEdit widgets. Source and type of all events generated by monitored objects are passed to this eventFilter, evaluated and passed on to the next hierarchy level.

  • When a QLineEdit widget gains input focus (QEvent.FocusIn), display the stored value from filter dict with full precision
  • When a key is pressed inside the text field, set the spec_edited flag to True.
  • When a QLineEdit widget loses input focus (QEvent.FocusOut), store current value in linear format with full precision (only if spec_edited == True) and display the stored value in selected format
frmt2cmplx(text, default=0.0)[source]

Convert format defined by cmbPZFrmt to real or complex

load_dict()[source]

Load all entries from filter dict fb.fil[0][‘zpk’] into the Zero/Pole/Gain list self.zpk and update the display via self._refresh_table(). The explicit np.array( … ) statement enforces a deep copy of fb.fil[0], otherwise the filter dict would be modified inadvertedly.

The filter dict is a “normal” numpy float array for z / p / k values The ZPK register self.zpk should be a list of float ndarrays to allow for different lengths of z / p / k subarrays while adding / deleting items.?

process_sig_rx(dict_sig=None)[source]

Process signals coming from sig_rx

setup_signal_slot()[source]

Setup setup signal-slot connections

class pyfda.input_widgets.input_pz.ItemDelegate(parent)[source]

The following methods are subclassed to replace display and editor of the QTableWidget.

  • displayText() displays the data stored in the table in various number formats
  • createEditor() creates a line edit instance for editing table entries
  • setEditorData() pass data with full precision and in selected format to editor
  • setModelData() pass edited data back to model (self.zpk)
createEditor(parent, options, index)[source]

Neet to set editor explicitly, otherwise QDoubleSpinBox instance is created when space is not sufficient?! editor: instance of e.g. QLineEdit (default) index: instance of QModelIndex options: instance of QStyleOptionViewItemV4

displayText(text, locale)[source]

Display text with selected format (cartesian / polar - to be implemented) and number of places

text: string / QVariant from QTableWidget to be rendered locale: locale for the text

initStyleOption(option, index)[source]

Initialize option with the values using the index index. All items are passed to the original initStyleOption() which then calls displayText().

Afterwards, check whether a pole (index.column() == 1 )is outside the UC and color item background accordingly (not implemented yet).

setEditorData(editor, index)[source]

Pass the data to be edited to the editor: - retrieve data with full accuracy (places=-1) from zpk (in float format) - represent it in the selected format (Cartesian, polar, …)

editor: instance of e.g. QLineEdit index: instance of QModelIndex

setModelData(editor, model, index)[source]

When editor has finished, read the updated data from the editor, convert it to complex format and store it in both the model (= QTableWidget) and in zpk. Finally, refresh the table item to display it in the selected format (via to be defined) and normalize the gain.

editor: instance of e.g. QLineEdit model: instance of QAbstractTableModel index: instance of QModelIndex

text(item)[source]

Return item text as string transformed by self.displayText()

class pyfda.input_widgets.input_pz.ItemDelegateAnti(parent)[source]

The following methods are subclassed to replace display and editor of the QTableWidget.

displayText() displays number with n_digits without sacrificing precision of the data stored in the table.

displayText(self, Any, QLocale) → str[source]
pyfda.input_widgets.input_pz.classes = {'Input_PZ': 'P/Z'}

display name

Type:Dict containing class name

input_info

Widget for displaying infos about filter and filter design method and debugging infos as well

class pyfda.input_widgets.input_info.Input_Info(parent)[source]

Create widget for displaying infos about filter specs and filter design method

load_dict()[source]

update docs and filter performance

process_sig_rx(dict_sig=None)[source]

Process signals coming from sig_rx

pyfda.input_widgets.input_info.classes = {'Input_Info': 'Info'}

display name

Type:Dict containing class name

input_files

Widget for exporting / importing and saving / loading filter data

class pyfda.input_widgets.input_files.Input_Files(parent)[source]

Create the widget for saving / loading data

about_window()[source]

Display an “About” window with copyright and version infos

file_dump(fOut)[source]

Dump file out in custom text format that apply tool can read to know filter coef’s

load_filter()[source]

Load filter from zipped binary numpy array or (c)pickled object to filter dictionary and update input and plot widgets

save_filter()[source]

Save filter as zipped binary numpy array or pickle object

pyfda.input_widgets.input_files.classes = {'Input_Files': 'Files'}

display name

Type:Dict containing class name

input_fixpoint_specs

The configuration file pyfda.conf lists which fixpoint classes (e.g. FIR_DF and IIR_DF1) can be used with which filter design algorithm. tree_builder parses this file and writes all fixpoint modules into the list fb.fixpoint_widgets_list. The input widget pyfda.input_widgets.input_fixpoint_specs constructs a combo box from this list with references to all successfully imported fixpoint modules. The currently selected fixpoint widget (e.g. FIR_DF) is imported from Package fixpoint_widgets together with the referenced picture.

Each fixpoint module / class contains a widget that is constructed using helper classes from fixpoint_widgets.fixpoint_helpers.py. The widgets allow entering fixpoint specifications like word lengths and formats for input, output and internal structures (like an accumulator) for each class. It also contains a reference to a picture showing the filter topology.

Details of the mechanism and the module are described in input_widgets.input_fixpoint_specs.