Example #1
0
 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)))
Example #2
0
 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)))
Example #3
0
 def _coerce(self, x: Expression):
     assert isinstance(x, hl.expr.StructExpression)
     assert list(x.keys()) == list(self.cases.keys())
     raise NotImplementedError()
Example #4
0
 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()})
Example #5
0
 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()})