Closed
Description
Reproducing code example:
import numpy as np
x, y = np.array([-969100.0]), np.array([-4457000.0])
# This works
"%.4g, %.4g" % (x, y)
# This errors
"{:.4g}, {:.4g}".format(x, y)
Error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported format string passed to numpy.ndarray.__format__
NumPy/Python version information:
1.15.4 3.7.1 (default, Nov 6 2018, 18:45:35)
[Clang 10.0.0 (clang-1000.11.45.5)]
OS: macOS High Sierra and Linux (Travis CI)
This happened when upgrading a codebase using the pyupgrade tool. %g
and {:g}
work the same for builtin types. Is this a NumPy bug?
Metadata
Metadata
Assignees
Labels
No labels