straditize.widgets.samples_table module

A table for manipulating samples

This module defines the sample editors, either for editing the samples in the straditizer image (SingleCrossMarksEditor) or in a separate Figure (MultiCrossMarksEditor)

Disclaimer

Copyright (C) 2018-2019 Philipp S. Sommer

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Classes

MultiCrossMarksEditor(straditizer[, axes])

An editor for cross marks in multiple axes

MultiCrossMarksModel(marks, columns, straditizer)

A table model to handle multiple connected cross marks in different axes

MultiCrossMarksView(marks, full_df, *args, …)

A table view set up by cross marks from multiple axes

SingleCrossMarksEditor(straditizer[, axes])

The editor for cross marks on a single axes

SingleCrossMarksModel(*args, **kwargs)

A table model to handle cross marks within one single axis

SingleCrossMarksView(marks, full_df, *args, …)

A table for visualizing marks from a single axes

class straditize.widgets.samples_table.MultiCrossMarksEditor(straditizer, axes=None, *args, **kwargs)[source]

Bases: psyplot_gui.common.DockMixin, PyQt5.QtWidgets.QWidget

An editor for cross marks in multiple axes

Parameters

Attributes

cb_plot_lines

Plot the reconstructed data

straditizer

A weakref to the

Methods

create_view([axes])

Create the MultiCrossMarksView of the editor

maybe_show_selection_only()

maybe_tabify()

maybe_zoom_to_selection()

save_samples()

Save the samples to the straditizer without removing them

to_dock(main[, title, position, docktype])

toggle_cb_selection_only()

toggle_cb_zoom_to_selection()

toggle_fit2selection()

Enable the fitting so selected digitized data

toggle_fmt_button(text)

toggle_plot_lines()

update_format()

Update the format of the table

Classes

dock_cls

The QDockWidget for the DataFrameEditor

cb_plot_lines = None

Plot the reconstructed data

create_view(axes=None)[source]

Create the MultiCrossMarksView of the editor

Parameters

axes (list of matplotlib.axes.Axes) – The matplotlib axes for the marks

dock_cls

alias of psyplot_gui.dataframeeditor.DataFrameDock

maybe_show_selection_only()[source]
maybe_tabify()[source]
maybe_zoom_to_selection()[source]
save_samples()[source]

Save the samples to the straditizer without removing them

straditizer = None

A weakref to the straditizer

to_dock(main, title=None, position=None, docktype='df', *args, **kwargs)[source]
toggle_cb_selection_only()[source]
toggle_cb_zoom_to_selection()[source]
toggle_fit2selection()[source]

Enable the fitting so selected digitized data

toggle_fmt_button(text)[source]
toggle_plot_lines()[source]
update_format()[source]

Update the format of the table

class straditize.widgets.samples_table.MultiCrossMarksModel(marks, columns, straditizer, axes=None, occurences_value=-9999)[source]

Bases: PyQt5.QtCore.QAbstractTableModel

A table model to handle multiple connected cross marks in different axes

Parameters

Methods

columnCount([index])

The number of rows in the table

data(self, QModelIndex, role)

delRow(irow)

flags(index)

Set flags

get_cell_mark(row, column)

Get the mark for a given cell in the table

get_format()

Return current format

headerData(section, orientation[, role])

Set header data

insertRow(irow[, xa, ya])

Insert a row into the table

load_new_marks(mark)

Add a new mark into the table after they have been added by the user

plot_lines()

Connect the samples through visual lines

remove_lines()

Remove the lines

remove_mark(mark)

Remove a mark from the table after it has been removed by the user

reset()

Reset the model

rowCount([index])

The number of rows in the table

setData(index, value[, role, change_type])

Cell content change

set_format(fmt)

Change display format

set_marks(marks, columns)

Set the marks attribute from the given columns

sort_marks()

Sort the marks based on there y-position

update_after_move(old_pos, mark)

update_lines()

Update the lines or plot them

Attributes

df

Get the samples_locs

fig

The figure of the cross marks

iter_marks

Iter over all marks in the marks attribute

lines

A list of matplotlib.lines.Line2D that connects the cross marks

marks

A list [float, list] where the first float is the vertical

columnCount(index=<PyQt5.QtCore.QModelIndex object>)[source]

The number of rows in the table

data(self, QModelIndex, role: int = Qt.DisplayRole) → Any[source]
delRow(irow)[source]
property df

Get the samples_locs

property fig

The figure of the cross marks

flags(index)[source]

Set flags

get_cell_mark(row, column)[source]

Get the mark for a given cell in the table

Parameters
  • row (int) – The row of the cell

  • column (int) – The column of the cell

Returns

The corresponding mark from the marks attribute

Return type

straditize.cross_mark.CrossMarks

get_format()[source]

Return current format

headerData(section, orientation, role=0)[source]

Set header data

insertRow(irow, xa=None, ya=None)[source]

Insert a row into the table

Parameters

irow (int) – The row index. If irow is equal to the length of the marks, the rows will be appended

property iter_marks

Iter over all marks in the marks attribute

lines = []

A list of matplotlib.lines.Line2D that connects the cross marks and plots a reconstruction based on them

load_new_marks(mark)[source]

Add a new mark into the table after they have been added by the user

Parameters

mark (straditize.cross_mark.CrossMarks) – The added mark

marks = []

A list [float, list] where the first float is the vertical position and the second list is a list of the corresponding CrossMarks instances

plot_lines()[source]

Connect the samples through visual lines

remove_lines()[source]

Remove the lines

remove_mark(mark)[source]

Remove a mark from the table after it has been removed by the user

Parameters

mark (straditize.cross_mark.CrossMarks) – The removed mark

reset()[source]

Reset the model

rowCount(index=<PyQt5.QtCore.QModelIndex object>)[source]

The number of rows in the table

setData(index, value, role=2, change_type=None)[source]

Cell content change

set_format(fmt)[source]

Change display format

set_marks(marks, columns)[source]

Set the marks attribute from the given columns

Parameters
sort_marks()[source]

Sort the marks based on there y-position

update_after_move(old_pos, mark)[source]
update_lines()[source]

Update the lines or plot them

See also

plot_lines()

class straditize.widgets.samples_table.MultiCrossMarksView(marks, full_df, *args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QTableView

A table view set up by cross marks from multiple axes

The model for this table is the MultiCrossMarksModel

Parameters

Methods

contextMenuEvent(event)

Reimplement Qt method

delete_selected_rows()

fit2data()

Fit the selected cells to the full_df

init_model(marks, *args, **kwargs)

Initialize the table MultiCrossMarksModel

insert_row_above_selection()

Insert a row above the selection

insert_row_below_selection()

Insert a row below the selection

moveCursor(cursor_action, modifiers)

Update the table position.

resizeEvent(event)

Update the frozen column dimensions.

scrollTo(index, hint)

Scroll the table.

setup_menu()

Setup context menu

show_all_marks()

Show all marks

show_selected_marks_only()

Show only the marks selected in the table

update_section_height(logical_index, …)

Update the vertical width of the frozen column when a

update_section_width(logical_index, …)

Update the horizontal width of the frozen column when a

zoom_to_cells(rows, cols)

Zoom to specific cells in the plot

zoom_to_selection()

Zoom to the selected cells in the plot

Attributes

full_df

The pandas.DataFrame representing the full digitized data

contextMenuEvent(event)[source]

Reimplement Qt method

delete_selected_rows()[source]
fit2data()[source]

Fit the selected cells to the full_df

full_df = None

The pandas.DataFrame representing the full digitized data from the straditize.binary.DataReader.full_df data frame

init_model(marks, *args, **kwargs)[source]

Initialize the table MultiCrossMarksModel

insert_row_above_selection()[source]

Insert a row above the selection

insert_row_below_selection()[source]

Insert a row below the selection

moveCursor(cursor_action, modifiers)[source]

Update the table position.

Updates the position along with the frozen column when the cursor (selector) changes its position

resizeEvent(event)[source]

Update the frozen column dimensions.

Updates takes place when the enclosing window of this table reports a dimension change

scrollTo(index, hint)[source]

Scroll the table.

It is necessary to ensure that the item at index is visible. The view will try to position the item according to the given hint. This method does not takes effect only if the frozen column is scrolled.

setup_menu()[source]

Setup context menu

show_all_marks()[source]

Show all marks

show_selected_marks_only()[source]

Show only the marks selected in the table

See also

show_all_marks()

update_section_height(logical_index, old_size, new_size)[source]

Update the vertical width of the frozen column when a change takes place on any of the rows

update_section_width(logical_index, old_size, new_size)[source]

Update the horizontal width of the frozen column when a change takes place in the first column of the table

zoom_to_cells(rows, cols)[source]

Zoom to specific cells in the plot

Parameters
  • rows (list of int) – The row indices of the cells

  • cols (list of int) – The column indicies of the cells

zoom_to_selection()[source]

Zoom to the selected cells in the plot

class straditize.widgets.samples_table.SingleCrossMarksEditor(straditizer, axes=None, *args, **kwargs)[source]

Bases: straditize.widgets.samples_table.MultiCrossMarksEditor

The editor for cross marks on a single axes

Parameters

Methods

create_view([axes])

Create the SingleCrossMarksView of the editor

save_samples()

Save the samples to the straditizer without removing them

create_view(axes=None)[source]

Create the SingleCrossMarksView of the editor

Parameters

axes (list of matplotlib.axes.Axes) – The matplotlib axes for the marks

save_samples()[source]

Save the samples to the straditizer without removing them

class straditize.widgets.samples_table.SingleCrossMarksModel(*args, **kwargs)[source]

Bases: straditize.widgets.samples_table.MultiCrossMarksModel

A table model to handle cross marks within one single axis

Parameters
  • column_bounds (np.ndarray of shape (N, 2)) – The column boundaries

  • y0 (float) – The upper extent of the data image

Methods

columnCount([index])

The number of rows in the table

delRow(irow)

get_cell_mark(row, column)

Get the mark for a given cell in the table

insertRow(irow[, xa, ya])

Insert a row into the table

load_new_marks(mark)

Add a new mark into the table after they have been added by the user

plot_lines()

Connect the samples through visual lines

remove_mark(mark)

Remove a mark from the table after it has been removed by the user

set_marks(marks, columns)

Set the marks attribute from the given columns

update_after_move(old_pos, mark)

update_lines()

Update the lines or plot them

Attributes

df

Get the samples_locs

iter_marks

Iter over all marks in the marks attribute

marks

A list of tuples like (float, mark) where float is the y-pixel

columnCount(index=<PyQt5.QtCore.QModelIndex object>)[source]

The number of rows in the table

delRow(irow)[source]
property df

Get the samples_locs

get_cell_mark(row, column)[source]

Get the mark for a given cell in the table

Parameters
  • row (int) – The row of the cell

  • column (int) – The column of the cell

Returns

The corresponding mark from the marks attribute

Return type

straditize.cross_mark.CrossMarks

insertRow(irow, xa=None, ya=None)[source]

Insert a row into the table

Parameters

irow (int) – The row index. If irow is equal to the length of the marks, the rows will be appended

property iter_marks

Iter over all marks in the marks attribute

load_new_marks(mark)[source]

Add a new mark into the table after they have been added by the user

Parameters

mark (straditize.cross_mark.CrossMarks) – The added mark

marks = []

A list of tuples like (float, mark) where float is the y-pixel and mark is the corresponding straditize.cross_mark.CrossMarks instance

plot_lines()[source]

Connect the samples through visual lines

remove_mark(mark)[source]

Remove a mark from the table after it has been removed by the user

Parameters

mark (straditize.cross_mark.CrossMarks) – The removed mark

set_marks(marks, columns)[source]

Set the marks attribute from the given columns

Parameters
update_after_move(old_pos, mark)[source]
update_lines()[source]

Update the lines or plot them

See also

plot_lines()

class straditize.widgets.samples_table.SingleCrossMarksView(marks, full_df, *args, **kwargs)[source]

Bases: straditize.widgets.samples_table.MultiCrossMarksView

A table for visualizing marks from a single axes

Parameters

Methods

fit2data()

Fit the selected cells to the full_df

init_model(marks, *args, **kwargs)

Initialize the table SingleCrossMarksModel

zoom_to_cells(rows, cols)

Zoom to specific cells in the plot

fit2data()[source]

Fit the selected cells to the full_df

init_model(marks, *args, **kwargs)[source]

Initialize the table SingleCrossMarksModel

Parameters

%(SingleCrossMarksModel.parameters)s

zoom_to_cells(rows, cols)[source]

Zoom to specific cells in the plot

Parameters
  • rows (list of int) – The row indices of the cells

  • cols (list of int) – The column indicies of the cells