8000 Can't do a formatted print of a <class 'numpy.core.memmap.memmap'> returned by a.mean(a) · Issue #8108 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Can't do a formatted print of a <class 'numpy.core.memmap.memmap'> returned by a.mean(a) #8108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Christopher-Field opened this issue Oct 2, 2016 · 1 comment

Comments

@Christopher-Field
Copy link

The second line of the program fragment below succeeds if b is a regular numpy array
but generates a TypeError if b is a memory mapped array (memmap).

m2 = b.mean()
print("The mean of b is {:f}.".format(m2))

TypeError: non-empty format string passed to object.format

The work around is a specific type change as
print("The mean of b is {:f}.".format(float(m2)))

A program demonstrating the success and failure is attached. I have observed the error in python 2.7 with numpy 1.10.4, python 3.5 with numpy 1.10.4, and pythion 3.5 with numpy 1.11.1.
I am running OS X 10.10.5.

memmap_error.py.zip

@ahaldane
Copy link
Member

This is fixed in 1.12 by #7406.

I'm going to close, thanks for the report.

(feel free to reopen if I'm wrong about that. I checked python2/numpy1.12 and your example works)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0