Skip to content

Why is scalar turned to 1d np array #759

@tianshub

Description

@tianshub

Describe the bug
Why is scalar turned into a 1d np array here:

if np.isscalar(x):
return check_nan(np.array([x]))

instead of just np.array(x)?

This result in warning messages like:

DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)

in the summary.py when converting back to float.

Minimal runnable code to reproduce the behavior

from tensorboardX import SummaryWriter
...

Expected behavior
Proper type conversion.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment
What is the result of
pip list|grep -E "torch|proto|tensor"
If the version is too old, please try to update first.

Python environment
Which version of python are you using? Did you use Andconda or Virtualenv?

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions