funsor icon indicating copy to clipboard operation
funsor copied to clipboard

Casting between real and bint

Open samanklesaria opened this issue 5 years ago • 2 comments

Is there currently a way to cast a funsor with real output to bint? Or vice versa? This would be particularly useful for indexing.

samanklesaria avatar Aug 07 '20 21:08 samanklesaria

For Tensor and Number you can pull out the data and re-wrap in a funsor. That is indeed hacky, and we do not have first class support for casting.

fritzo avatar Aug 08 '20 02:08 fritzo

@bogiebro can you say more about your use case? Maybe give some example code?

I'd like to support your casting usage. I think we could generalize the scalar type Bint[n] to a type of homogeneously-bounded arrays Bints[(n,) + shape], and maybe later to an array type like Array[dtype, shape] (encompassing both Reals[-] and Bints[-]), maybe even similar to NumPy's ArrayLike.

fritzo avatar Aug 18 '20 15:08 fritzo