Skip to content

Commit

Permalink
DOC: Update mode parameter description to account for shape #22643 (#…
Browse files Browse the repository at this point in the history
…22655)

The `shape` parameter must be specified when opened in appending mode. Docstring
and exception message wording are updated to reflect this.

Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
  • Loading branch information
mkiffer and rossbar committed Nov 24, 2022
1 parent 145b5a7 commit a872fd7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion numpy/core/memmap.py
Expand Up @@ -59,6 +59,7 @@ class memmap(ndarray):
| 'r+' | Open existing file for reading and writing. |
+------+-------------------------------------------------------------+
| 'w+' | Create or overwrite existing file for reading and writing. |
| | If ``mode == 'w+'`` then `shape` must also be specified. |
+------+-------------------------------------------------------------+
| 'c' | Copy-on-write: assignments affect data in memory, but |
| | changes are not saved to disk. The file on disk is |
Expand Down Expand Up @@ -220,7 +221,7 @@ def __new__(subtype, filename, dtype=uint8, mode='r+', offset=0,
) from None

if mode == 'w+' and shape is None:
raise ValueError("shape must be given")
raise ValueError("shape must be given if mode == 'w+'")

if hasattr(filename, 'read'):
f_ctx = nullcontext(filename)
Expand Down

0 comments on commit a872fd7

Please sign in to comment.