Skip to content

load does not accept pathlib.Path in mmap_mode #11342

@paulmueller

Description

@paulmueller

#6660, #665, and #6418 added support for pathlib.Path in numpy.load.

However, if mmap_mode is not None in numpy.load, I get an error:

  File ".../python3.6/site-packages/numpy/lib/format.py", line 747, in open_memmap
    raise ValueError("Filename must be a string.  Memmap cannot use"
ValueError: Filename must be a string.  Memmap cannot use existing file handles.

The problem is that format.open_memmap does not yet support pathlib.Path.

https://github.com/numpy/numpy/blob/master/numpy/lib/format.py#L703
https://github.com/numpy/numpy/blob/master/numpy/lib/npyio.py#L430

Please let me know whether you would accept a PR for this.

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