@@ -396,6 +396,63 @@ def test_different_domains(self):
396396 self .send_signal (w .Inputs .reference , None )
397397 self .assertFalse (w .Error .diff_domains .is_shown ())
398398
399+ def test_different_metas (self ):
400+ """
401+ Test weather widget do not show error when data and a reference have
402+ domain that differ only in metas
403+ """
404+ w = self .widget
405+
406+ domain = Domain ([ContinuousVariable ("a" ), ContinuousVariable ("b" )],
407+ metas = [ContinuousVariable ("c" )])
408+ data = Table (
409+ domain , np .random .rand (2 , len (domain .attributes )),
410+ metas = np .random .rand (2 , len (domain .metas )))
411+
412+ # same domain with same metas no error
413+ self .send_signal (w .Inputs .data , data )
414+ self .send_signal (w .Inputs .reference , data [:1 ])
415+ self .assertFalse (w .Error .diff_domains .is_shown ())
416+
417+ # same domain with different metas no error
418+ domain_ref = Domain (domain .attributes ,
419+ metas = [ContinuousVariable ("d" )])
420+ reference = Table (
421+ domain_ref , np .random .rand (1 , len (domain_ref .attributes )),
422+ metas = np .random .rand (1 , len (domain .metas )))
423+ self .send_signal (w .Inputs .data , data )
424+ self .send_signal (w .Inputs .reference , reference )
425+ self .assertFalse (w .Error .diff_domains .is_shown ())
426+
427+ # same domain with different order - no error
428+ domain_ref = Domain (domain .attributes [::- 1 ])
429+ reference = Table (
430+ domain_ref , np .random .rand (1 , len (domain_ref .attributes )))
431+ self .send_signal (w .Inputs .data , data )
432+ self .send_signal (w .Inputs .reference , reference )
433+ self .assertFalse (w .Error .diff_domains .is_shown ())
434+
435+ # same domain with different number of metas no error
436+ domain_ref = Domain (
437+ domain .attributes ,
438+ metas = [ContinuousVariable ("d" ), ContinuousVariable ("e" )])
439+ reference = Table (
440+ domain_ref , np .random .rand (1 , len (domain_ref .attributes )),
441+ metas = np .random .rand (1 , len (domain_ref .metas )))
442+ self .send_signal (w .Inputs .data , data )
443+ self .send_signal (w .Inputs .reference , reference )
444+ self .assertFalse (w .Error .diff_domains .is_shown ())
445+
446+ # different domain with same metas - error shown
447+ domain_ref = Domain (domain .attributes + (ContinuousVariable ("e" ),),
448+ metas = [ContinuousVariable ("c" )])
449+ reference = Table (
450+ domain_ref , np .random .rand (1 , len (domain_ref .attributes )),
451+ metas = np .random .rand (1 , len (domain_ref .metas )))
452+ self .send_signal (w .Inputs .data , data )
453+ self .send_signal (w .Inputs .reference , reference )
454+ self .assertTrue (w .Error .diff_domains .is_shown ())
455+
399456
400457if __name__ == "__main__" :
401458 unittest .main ()
0 commit comments