All projects

Upstream commits

tensorflow

tensorflow/tensorflow

View on GitHub

2 commits

  1. Call _with_index_update_helper directly in its regression test
    The `_with_index_*` methods are attached to `Tensor` as `functools.partial` objects, and `functools.partial` became a descriptor in Python 3.13. On 3.13 and later it binds the tensor as the helper's first argument; before 3.13 it does not, so the tensor has to be passed explicitly. Reaching the helper through the method therefore needs opposite call sites on either side of that version boundary, and TensorFlow builds against both. Call `_with_index_update_helper` directly instead. That is the function this change fixes, and it takes the same arguments on every supported version.
  2. Fix AttributeError in tnp around, heaviside and average
    `_scalar` was fixed to call `math_ops.cast` because `Tensor` only has an `astype` method after `enable_numpy_methods_on_tensor()` has run. Five more `astype` calls, in four other functions, still fail without that opt-in, which is what a plain `import tensorflow` gives you: >>> tnp.around([1.5, 2.5]) AttributeError: EagerTensor object has no attribute 'astype'. `around` casts back to the argument's dtype on every path, so it fails on any input, taking `tnp.round` and `Tensor.__round__` with it. `heaviside` and `average` fail on integer input, `_with_index_update_helper` on any. `astype` is installed as an alias of `math_ops.cast`, so calling `cast` directly is the same operation without the dependency on the opt-in. Neither module calls `astype` after this change. The regression tests go in the module added for the `_scalar` fix, plus an `np_array_ops` counterpart. Both deliberately skip the opt-in, which is what makes these paths observable in a test.

Updated daily, last on 2026-11-16. By Christian Aurich Zanettini Martins · All projects