def _coerce(self, x: Expression): assert isinstance(x, hl.expr.DictExpression) if not self.kc._requires_conversion(x.dtype.key_type): # fast path return x.map_values(self.vc.coerce) else: return hl.dict(hl.map(lambda e: (self.kc.coerce(e[0]), self.vc.coerce(e[1])), hl.array(x)))
def _coerce(self, x: Expression): assert isinstance(x, hl.expr.StructExpression) assert list(x.keys()) == list(self.cases.keys()) raise NotImplementedError()
def _coerce(self, x: Expression): assert isinstance(x, hl.expr.StructExpression) assert list(x.keys()) == list(self.fields.keys()) return hl.struct(**{name: c.coerce(x[name]) for name, c in self.fields.items()})