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

[ENH] OWMDS, OWLinearProjection: save selection in workflow #2301

Merged
merged 1 commit into from
Jul 27, 2017

Conversation

kernc
Copy link
Contributor

@kernc kernc commented May 9, 2017

Issue

Fixes #2182

Description of changes
Includes
  • Code changes
  • Tests
  • Documentation

@codecov-io
Copy link

codecov-io commented May 9, 2017

Codecov Report

Merging #2301 into master will increase coverage by 0.01%.
The diff coverage is 91.66%.

@@            Coverage Diff             @@
##           master    #2301      +/-   ##
==========================================
+ Coverage   74.53%   74.55%   +0.01%     
==========================================
  Files         321      321              
  Lines       56134    56140       +6     
==========================================
+ Hits        41838    41853      +15     
+ Misses      14296    14287       -9

@astaric
Copy link
Member

astaric commented May 9, 2017

Selections are not really context settings as they depend not only on the columns in the dataset but on the number of rows as well. Have you considered using schema only settings?

@kernc kernc changed the title OWMDS, OWLinearProjection: save selection as context setting [WIP] OWMDS, OWLinearProjection: save selection as context setting May 11, 2017
@kernc
Copy link
Contributor Author

kernc commented May 12, 2017

The problem I have with schema_only settings is that there's additional boilerplate associated with using them:

    def closeContext(self):
        if self.current_context is not None:
            self.selection = None
        super().closeContext()

Short, but very intricate.

@janezd
Copy link
Contributor

janezd commented May 26, 2017

File -> Sample -> MDS. Select all points in MDS. Decrease the sample size in Sample. MDS crashes due to selection indices out of range. Linear projection probably as well.

A saved context setting is reused when "useful", e.g. if the setting includes a variable, the variable has to appear in the domain for the context to be useful. In this sense, the context here is not the domain but the sample size (e.g. the saved selection is "useful" if there is enough data for these indices). However, this context would be too vaguely defined, so checking the domain (DomainContextHandler) is OK.

One quick solution would be to discard the selection (after openContext) if max(selection_indices) >= len(data). A slightly better solution is to have DomainAndDataSizeContextHandler, but it can still lead to weird selections. The safest solution would be DataHashContextHandler, where the has is computed over X, Y and metas. The latter would also make sense for some other widgets.

janezd
janezd previously requested changes May 26, 2017
Copy link
Contributor

@janezd janezd left a comment

Choose a reason for hiding this comment

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

Also, add tests that will check for this.

@kernc kernc force-pushed the mds-save-selection branch 2 times, most recently from 21d9aa8 to 17dd67e Compare May 26, 2017 13:34
@kernc
Copy link
Contributor Author

kernc commented May 26, 2017

Right. How is this?

@@ -508,6 +508,14 @@ def closeContext(self):
reinitializing the user interface (e.g. combo boxes) with the new
data.
"""
# Clear schema-only settings when *closing* the context
# FIXME: Sadly, schema-only settings aren't cleared when non-contextual
Copy link
Member

Choose a reason for hiding this comment

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

Actually, they are.

As non-context-aware widgets only load settings when a new instance of the widget is put on the canvas, this is achieved by not updating default values. See https://github.com/biolab/orange3/blob/master/Orange/widgets/settings.py#L508

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But what if the same instance of widget but passed different data, as described here?

# Clear schema-only settings when *closing* the context
# FIXME: Sadly, schema-only settings aren't cleared when non-contextual
# SettingsHandler is used
if self.current_context is not None:
Copy link
Member

Choose a reason for hiding this comment

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

@astaric astaric dismissed janezd’s stale review July 7, 2017 08:01

As the feature was implemented in a simple way, the suggestion is no longer relevant.

@@ -1028,8 +1031,9 @@ def commit(self):
if output is not None and self._selection_mask is not None and \
numpy.any(self._selection_mask):
subset = output[self._selection_mask]
self.selection_indices = numpy.flatnonzero(self._selection_mask)
Copy link
Member

Choose a reason for hiding this comment

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

For settings, primitive types > numpy, as they can be serialized to json, resulting in human readable settings.

@astaric
Copy link
Member

astaric commented Jul 7, 2017

This looks good to me, rebase when possible so we can merge.

@astaric astaric changed the title [WIP] OWMDS, OWLinearProjection: save selection as context setting [ENH] OWMDS, OWLinearProjection: save selection in workflow Jul 7, 2017
@kernc kernc force-pushed the mds-save-selection branch 2 times, most recently from df9b73c to 1bc6449 Compare July 7, 2017 12:21
@@ -103,7 +103,7 @@ class Outputs:

settingsHandler = settings.DomainContextHandler()

max_iter = settings.Setting(300)
max_iter = settings.Setting(10)
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this change doing in a commit "save selection in workflow" ?!?

Did you change this while testing and accidentally committed it?
Or decided to change some defaults and make it less obvious by not mentioning it at all and/or putting it in its own commit.

@lanzagar lanzagar added this to the 3.4.5 milestone Jul 26, 2017
@lanzagar lanzagar merged commit 8f76f5d into biolab:master Jul 27, 2017
@jerneju jerneju mentioned this pull request Aug 22, 2017
3 tasks
ales-erjavec added a commit to ales-erjavec/orange3 that referenced this pull request Oct 17, 2017
ales-erjavec added a commit to ales-erjavec/orange3 that referenced this pull request Oct 17, 2017
ales-erjavec added a commit to ales-erjavec/orange3 that referenced this pull request Oct 17, 2017
* undo changes to settings from biolabgh-2301
* change selection restore in scatter plot and linear projection accordingly
ales-erjavec added a commit to ales-erjavec/orange3 that referenced this pull request Oct 18, 2017
* undo changes to settings from biolabgh-2301
* change selection restore in scatter plot and linear projection accordingly
ales-erjavec added a commit to ales-erjavec/orange3 that referenced this pull request Oct 23, 2017
* undo changes to settings from biolabgh-2301
* change selection restore in scatter plot and linear projection accordingly
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.

6 participants