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

Statistics: Fix ComputeValue.__eq__ #1076

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion orangecontrib/text/widgets/owstatistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ def __call__(self, data: Corpus) -> np.ndarray:
return self.function(data, self.pattern, self.source, lambda: True)[0]

def __eq__(self, other):
return self.function == other.function and self.pattern == other.pattern
return type(self) is type(other) and self.function == other.function \
and self.pattern == other.pattern

def __hash__(self):
return hash((self.function, self.pattern))
Expand Down
7 changes: 7 additions & 0 deletions orangecontrib/text/widgets/tests/test_owstatistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from AnyQt.QtWidgets import QPushButton

from Orange.data import Domain, StringVariable
from Orange.preprocess import SklImpute
from Orange.widgets.tests.base import WidgetTest
from Orange.widgets.tests.utils import simulate
from orangecontrib.text import Corpus
Expand Down Expand Up @@ -521,6 +522,12 @@ def test_migrate_settings(self):
]
self.assertListEqual(expected, widget.active_rules)

def test_preprocess_output(self):
self.send_signal(self.widget.Inputs.corpus, self.corpus)
output = self.get_output(self.widget.Outputs.corpus)
imputed = SklImpute()(output)
self.assertIsNotNone(imputed)


if __name__ == "__main__":
unittest.main()
Loading