as part of #7 I added the coercion dunders __bool__, __int__, __complex__, __index__ alongside __float__ that was already available.
these methods currently do e.g. float(self._backend.squeeze(self).value), but not all frameworks neatly support all coercions (e.g. bool for tf, TypeError: Using a tf.Tensor as a Python bool is not allowed.). this means that we have a dishomogeneous behavior across frameworks
I see two options: 1) we add non-abstract backend methods, like to_float; if a backend does not implement them, we raise a TypeError. 2) we support this in all frameworks (to_float is abstract), and come up with a workaround for frameworks that don't directly allow coercion to scalar
as part of #7 I added the coercion dunders
__bool__,__int__,__complex__,__index__alongside__float__that was already available.these methods currently do e.g.
float(self._backend.squeeze(self).value), but not all frameworks neatly support all coercions (e.g. bool for tf,TypeError: Using a tf.Tensor as a Python bool is not allowed.). this means that we have a dishomogeneous behavior across frameworksI see two options: 1) we add non-abstract backend methods, like
to_float; if a backend does not implement them, we raise a TypeError. 2) we support this in all frameworks (to_floatis abstract), and come up with a workaround for frameworks that don't directly allow coercion to scalar