Skip to content

tf.experimental.numpy.rad2deg fails on integer arrays and Python lists #129238

Closed

Description

@bodapatisaikrishna

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

binary

TensorFlow version

tf-nightly 2.23.0-dev20261014 (git v1.12.1-146947-gfcb676979cd)

Custom code

Yes

OS platform and distribution

macOS 15.7.2 (arm64)

Mobile device

No response

Python version

3.11.7

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

Unlike deg2rad, rad2deg does not convert its input or promote it to float. It just returns x * (180.0 / np.pi) (np_math_ops.py#L1000-L1001). So:

  • tnp.rad2deg([1.0, 2.0]) raises TypeError: can't multiply sequence by non-int of type 'float'
  • tnp.rad2deg(tnp.array(1)) raises TypeError: Cannot convert 57.29... to EagerTensor of dtype int64
  • tnp.rad2deg(np.array([1.0])) returns a numpy.ndarray, not a TF tensor

deg2rad handles all three correctly because it goes through _scalar(f, x, promote_to_float=True). rad2deg should do the same.

Standalone code to reproduce the issue

import numpy as np
import tensorflow.experimental.numpy as tnp

print(tnp.deg2rad(180))                 # works
print(type(tnp.rad2deg(np.array([1.0]))))  # numpy.ndarray, not a TF tensor
try:
  print(tnp.rad2deg([1.0, 2.0]))
except Exception as e:
  print(type(e).__name__, e)            # TypeError: can't multiply sequence by non-int of type 'float'
try:
  print(tnp.rad2deg(tnp.array(1)))
except Exception as e:
  print(type(e).__name__, e)            # TypeError: Cannot convert 57.29... to EagerTensor of dtype int64

Relevant log output

tf.Tensor(3.141592653589793, shape=(), dtype=float64)
<class 'numpy.ndarray'>
TypeError can't multiply sequence by non-int of type 'float'
TypeError Cannot convert 57.29577951308232 to EagerTensor of dtype int64

Activity

  1. added
    comp:apis
    comp:ops
    2.21.0
    on Oct 19, 2026
  2. Kayyuri commented on Oct 19, 2026

    @Kayyuri

    Hi @bodapatisaikrishna,
    Thanks for reporting the issue and submitting a fix for TensorFlow. Once the PR is merged, the issue will be resolved. We truly appreciate your initiative and the effort in contributing the fix.

  3. added a commit that references this issue on Oct 23, 2026
    adefc9a
  4. google-ml-butler commented on Oct 23, 2026

    @google-ml-butler

    Are you satisfied with the resolution of your issue?
    Yes
    No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

2.21.0awaiting PR mergecomp:apiscomp:opstype:bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions