lib/torch/tensor.rb in torch-rb-0.10.1 vs lib/torch/tensor.rb in torch-rb-0.10.2

- old
+ new

@@ -197,7 +197,15 @@ # not a method in native_functions.yaml # attribute in Python rather than method def real Torch.real(self) end + + def coerce(other) + if other.is_a?(Numeric) + [Torch.tensor(other), self] + else + raise TypeError, "#{self.class} can't be coerced into #{other.class}" + end + end end end