-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[WIP][ENH] Neighbors: data info displayed in status bar #4141
Conversation
|
||
@Inputs.data | ||
def set_data(self, data): | ||
self.data = data | ||
self._set_label_text("data") | ||
self._set_input_summary() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can place this into handleNewSignals()
instead. handleNewSignals()
is emitted on any input change.
|
||
@Inputs.reference | ||
def set_ref(self, refs): | ||
self.reference = refs | ||
self._set_label_text("reference") | ||
self._set_input_summary() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
|
||
def _set_output_summary(self): | ||
if self.data is None: | ||
self.Outputs.data.send(None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outputting the data is already handled in apply()
. Besides, it should not be sent twice, if not necessary.
|
||
indices = self._compute_indices() | ||
if np.any(indices): | ||
neighbors = self._data_with_similarity(indices) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calculating the neighbors just for sake of the info is wasteful, and unnecessary.
The "info" code could be placed in an apply
function, but if you insist to have a separate function for that, just pass it the neighbors
calculated in the apply()
.
@@ -541,7 +541,7 @@ def __init__(self, parent=None, **kwargs): | |||
fixedrb = QRadioButton("Fixed", checked=True) | |||
group.addButton(fixedrb, RandomFeatureSelectEditor.Fixed) | |||
kspin = QSpinBox( | |||
minimum=1, value=self.__k, | |||
minimum=1, maximum=10000000, value=self.__k, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change should be removed from this PR.
elif self.data is not None: | ||
n_data = len(self.data) | ||
elif self.reference is not None: | ||
n_refs = len(self.reference) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can shorten this by:
n_data = len(self.data) if self.data else 0
n_refs = len(self.reference) if self.reference else 0
and move the following else
statement into the second if
details = f"No data instances on input; " \ | ||
f"{n_refs} reference instances on input " | ||
|
||
self.info.set_input_summary(inst, details) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A shorter version:
if n_data or n_refs:
details = \
f"{n_data if n_data else 'No'} data instance(s) on input\n" \
f"{n_refs if n_refs else 'No'} reference instance(s) on input "
self.info.set_input_summary(f"{n_data} | {n_refs} ", details)
else:
self.info.set_input_summary(self.info.NoInput)
Along with code changed, a test and documentation update should come. |
Description of changes
Fixes #4114 - Info box removed and instead Input and Output data displayed in status bar.
Includes