def generate_cfg(self, grammar, head): symbol = head or Symbol(self.__class__.__name__) compatible = [] for _, other_cls in grammar.namespace.items(): if other_cls in self.exceptions: continue if hasattr(other_cls, "__name__") and other_cls.__name__ in self.exceptions: continue if self.interface.is_compatible(other_cls): compatible.append(other_cls) if not compatible: raise ValueError( "Cannot find compatible implementations for <class %s>" % self.interface ) return Subset(symbol.name, *compatible).generate_cfg(grammar, symbol)
def __init__(self, features: Subset("Subset", "Hello", "World", 1)): pass
def __init__(self, features: Subset("Subset", DiscreteValue(1, 5), "Hello", 1, None)): self.features = features
def __init__( self, features: Subset("Subset", DiscreteValue(1, 5), CategoricalValue("adam", "sgd")), ): pass
def __init__(self, features: Subset('Subset', Discrete(1, 5), 'Hello', 1, None)): self.features = features
def __init__(self, features: Subset('Subset', Discrete(1, 5), Categorical('adam', 'sgd'))): pass
def __init__(self, xs: Subset("xs", A, D)): self.xs = xs