Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rank: Move TableView and TableModel to gui #6098

Merged
merged 2 commits into from
Aug 28, 2022

Conversation

ajdapretnar
Copy link
Contributor

Issue

Rank's TableView and TableModel are not independent modules that can be called for other widgets.

Description of changes

Move the two classes to gui.py, so other widgets can use them.

Includes
  • Code changes
  • Tests
  • Documentation

@codecov
Copy link

codecov bot commented Aug 18, 2022

Codecov Report

Merging #6098 (263b782) into master (9d73b8e) will decrease coverage by 0.00%.
The diff coverage is 85.91%.

❗ Current head 263b782 differs from pull request most recent head 7bcc2f7. Consider uploading reports for the commit 7bcc2f7 to get more accurate results

@@            Coverage Diff             @@
##           master    #6098      +/-   ##
==========================================
- Coverage   86.63%   86.62%   -0.01%     
==========================================
  Files         315      315              
  Lines       67560    67559       -1     
==========================================
- Hits        58531    58524       -7     
- Misses       9029     9035       +6     

@janezd
Copy link
Contributor

janezd commented Aug 19, 2022

I agree, but I fear we already have a plentitude of table models and views. Quick check showed it may not be so bad; details below. Still, please

  • Rename TableModel into something more meaningful, e.g. BarTableModel (still, it is not the only model to provide bars)
  • Add a docstring
  • I'm not sure TableView adds anything that warrants moving it from owrank to widgets.gui. All visual settings and selection-related behaviour may be specific to the rank widget.

Now for my "brief analysis":

Models

General table models

orangewidget.utils.itemmodels.AbstractSortTableModel:
A sorting proxy table model that sorts its rows in fast numpy, avoiding potentially thousands of calls into `QSortFilterProxyModel.lessThan()` or any potentially costly reordering of original data. Override `sortColumnData()`, adapting it to your underlying model.
Orange.widgets.utils.itemmodels.AbstractSortTableModel(AbstractSortTableModel):
Add two deprecated methods for backward compatibility
Orange.widgets.utils.itemmodels.PyTableModel(AbstractSortTableModel):
A model for displaying python tables (sequences of sequences) in `QTableView objects`.
Orange.widgets.utils.itemmodels.TableModel(AbstractSortTableModel):
An adapter for using Orange.data.Table within Qt's Item View Framework. Also adds VariableStatsRole (min, max, etc.) and DomainRole (attr, class, meta)

Table models defined in widget modules (excluding specific models, such as those in Feature Statistics, Distance Matrix, Predictions...)

Orange.widgets.data.owtable.RichTableModel(TableModel):
Add BarRole and information for headers (attributes of attributes)
Orange.widgets.data.owrank.TableModel:
Add a BarRatioRole that returns Data, normalized between the extremes. In sorting, put NaNs last.

Views

Orange.widgets.utils.tableview.TableView(QTableView):
A QTableView subclass that is more suited for displaying large data models. Provides a `selectionFinished` signal that is emitted when selection is finished, but not during selecting.
orangewidget.gui.TableView(QTableView):
An auxiliary table view for use with PyTableModel in control areas. Essentially about sizing, and a delegate that may print some text in bold.
**I believe we should deprecate or at least rename this class** because it is being used instead of `QTableView`. It may be indeed useful in evaluation widgets, though I'm not sure - it may also be redundant there. There are some eclatant misuses, such as importing it to get an enum, which is actually defined in `QTableView`.</dd>

@ajdapretnar ajdapretnar force-pushed the rank-clean branch 2 times, most recently from a932b44 to d6dc149 Compare August 22, 2022 08:01
@ajdapretnar
Copy link
Contributor Author

@janezd I did as suggested. The alternative is to simply copy the code from Rank into OWCollocations (biolab/orange3-text#782), which would also simplify release-making (Collocations would depend on releasing master first).

I am fine with either option, whatever you think is best.

@@ -556,7 +556,7 @@ def test_concurrent_cancel(self):
class TestRankModel(GuiTest):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you, please, also move this test to Orange.widgets.tests.test_gui?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I just wasn't sure whether to rename the test...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize for being such a nazi. We, that is pylint and I, think that you should also clean and rearrange your imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know. I was waiting for hints from the lint run. I don't know how to run it locally so.... 🤷‍♀️

@ajdapretnar ajdapretnar force-pushed the rank-clean branch 2 times, most recently from add8eac to 24ce260 Compare August 24, 2022 07:00
@janezd janezd merged commit d243aef into biolab:master Aug 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants