Skip to content

np.average of memmap returns memmap 0d array instead of numpy scalar #7403

@lesteve

Description

@lesteve
import numpy as np
mm = np.memmap('/tmp/test.data', mode='w+', shape=4)
np.average(mm)

Output since 5ceab8f (a couple of days ago):

memmap(0.0)

Output before that (e.g. in 1.10.4):

0.0

This causes the scikit-learn using numpy master tests to fail, see this Travis log.

We have been bitten in the past by this in scikit-learn with .sum that has the same surprising behaviour (see scikit-learn/scikit-learn#6225). Shouldn't reduce operations on a memmap array always return a numpy scalar ?

cc @ogrisel.

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