def test_interaction_instance_missing_dimensions(self): """Test when a dimension is missing.""" with self.assertRaises(DimensionError) as exc: make_model_cls( dimensions={}, # missing "d" interaction=TransEInteraction(p=2), ) self.assertIsInstance(exc.exception, DimensionError) self.assertEqual({'d'}, exc.exception.expected) self.assertEqual(set(), exc.exception.given) self.assertEqual("Expected dimensions dictionary with keys {'d'} but got keys set()", str(exc.exception))
def test_interaction_resolver_lookup(self): """Test resolving the interaction function.""" model_cls = make_model_cls({"d": 3}, 'TransE', {'p': 2}) self._help_test_interaction_resolver(model_cls)
def test_interaction_builder(self): """Test resolving an interaction model.""" model_cls = make_model_cls({"d": 3}, TransEInteraction(p=2)) self._help_test_interaction_resolver(model_cls)
def test_interaction_resolver_cls(self): """Test resolving the interaction function.""" model_cls = make_model_cls({"d": 3}, TransEInteraction, {"p": 2}) self._help_test_interaction_resolver(model_cls)