8000 TypeError: unsupported format string passed to numpy.ndarray.__format__ · Issue #12491 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
TypeError: unsupported format string passed to numpy.ndarray.__format__ #12491
Closed
@hugovk

Description

@hugovk

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0