diff options
author | mkiffer <michaelkiffer@gmail.com> | 2022-11-24 11:01:54 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-23 16:01:54 -0800 |
commit | a872fd73e6e94727c7acf281b03789bd42cda086 (patch) | |
tree | 65f4fab4b1beb48815d4b8f178eb7c6c8e44ff93 | |
parent | 145b5a76b00a24aa458f2374990eb294496b2665 (diff) | |
download | numpy-a872fd73e6e94727c7acf281b03789bd42cda086.tar.gz |
DOC: Update mode parameter description to account for shape #22643 (#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>
-rw-r--r-- | numpy/core/memmap.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py index b0d9cb3af..21341b2e3 100644 --- a/numpy/core/memmap.py +++ b/numpy/core/memmap.py @@ -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 | @@ -220,7 +221,7 @@ class memmap(ndarray): ) 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) |