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

OWNeighbors: check matching of attributes only #4117

Closed
ajdapretnar opened this issue Oct 18, 2019 · 6 comments · Fixed by #4131
Closed

OWNeighbors: check matching of attributes only #4117

ajdapretnar opened this issue Oct 18, 2019 · 6 comments · Fixed by #4131
Assignees
Labels
bug A bug confirmed by the core team

Comments

@ajdapretnar
Copy link
Contributor

Describe the bug
Neighbors widget doesn't work when meta attributes are different. Should probably only check if X matches, since it doesn't consider metas anyway.

To Reproduce
Steps to reproduce the behavior:

  1. Import Images - Image Embedding.
  2. Import Images - Face Detector - Image Embedding.
  3. Send both to Neighbors.

Orange version:
3.23.1

Expected behavior
If attributes of both outputs match (data.domain.attributes == reference_data.domain.attributes), Neighbors works.

@ajdapretnar ajdapretnar added the bug A bug confirmed by the core team label Oct 18, 2019
@ajdapretnar
Copy link
Contributor Author

This seems to be already fixed a long time ago in #3555.
However, the domain matching fails on the latest release. Not on master. I suspect Variable.make has something to do with this.

@ajdapretnar
Copy link
Contributor Author

I think a release of the current master should fix this. A test would be nice. Domains have to come from two different sources I think - Image Embedding works well for testing.

@PrimozGodec
Copy link
Contributor

PrimozGodec commented Oct 22, 2019

I assume that it must be the same bug than at #4108 since both use a domain.transform. Also, the test is already available:

def test_different_metas(self):
"""
Test weather widget do not show error when data and a reference have
domain that differ only in metas
"""
w = self.widget
domain = Domain([ContinuousVariable("a"), ContinuousVariable("b")],
metas=[ContinuousVariable("c")])
data = Table(
domain, np.random.rand(2, len(domain.attributes)),
metas=np.random.rand(2, len(domain.metas)))
# same domain with same metas no error
self.send_signal(w.Inputs.data, data)
self.send_signal(w.Inputs.reference, data[:1])
self.assertFalse(w.Error.diff_domains.is_shown())
# same domain with different metas no error
domain_ref = Domain(domain.attributes,
metas=[ContinuousVariable("d")])
reference = Table(
domain_ref, np.random.rand(1, len(domain_ref.attributes)),
metas=np.random.rand(1, len(domain.metas)))
self.send_signal(w.Inputs.data, data)
self.send_signal(w.Inputs.reference, reference)
self.assertFalse(w.Error.diff_domains.is_shown())
# same domain with different order - no error
domain_ref = Domain(domain.attributes[::-1])
reference = Table(
domain_ref, np.random.rand(1, len(domain_ref.attributes)))
self.send_signal(w.Inputs.data, data)
self.send_signal(w.Inputs.reference, reference)
self.assertFalse(w.Error.diff_domains.is_shown())
# same domain with different number of metas no error
domain_ref = Domain(
domain.attributes,
metas=[ContinuousVariable("d"), ContinuousVariable("e")])
reference = Table(
domain_ref, np.random.rand(1, len(domain_ref.attributes)),
metas=np.random.rand(1, len(domain_ref.metas)))
self.send_signal(w.Inputs.data, data)
self.send_signal(w.Inputs.reference, reference)
self.assertFalse(w.Error.diff_domains.is_shown())
# different domain with same metas - error shown
domain_ref = Domain(domain.attributes + (ContinuousVariable("e"),),
metas=[ContinuousVariable("c")])
reference = Table(
domain_ref, np.random.rand(1, len(domain_ref.attributes)),
metas=np.random.rand(1, len(domain_ref.metas)))
self.send_signal(w.Inputs.data, data)
self.send_signal(w.Inputs.reference, reference)
self.assertTrue(w.Error.diff_domains.is_shown())

In #4131 I made a small addition to the test to also checks the output.

@ajdapretnar
Copy link
Contributor Author

If tests are already available, I can't understand how they could pass with the last release... Neighbors now doesn't work for demo workflow (lookalike).

@PrimozGodec
Copy link
Contributor

You are right, those tests didn't exactly cover the issue you had. The problem was that in this case, all attributes have the same names are different objects. I added a test case for that in #4131.

@ajdapretnar
Copy link
Contributor Author

Yeah, that was the case. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug confirmed by the core team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants