2727"""
2828from contextlib import contextmanager
2929from threading import RLock
30- import warnings
3130
3231import numpy as np
3332
4847
4948If this flag is set to ``True``, a single file handle is created and used. If
5049``False``, a new file handle is created every time the image is accessed.
51- If this flag is set to ``'auto'``, a ``DeprecationWarning`` will be raised, which
52- will become a ``ValueError`` in nibabel 3.0.0.
5350
5451If this is set to any other value, attempts to create an ``ArrayProxy`` without
5552specifying the ``keep_file_open`` flag will result in a ``ValueError`` being
5653raised.
5754
5855.. warning:: Setting this flag to a value of ``'auto'`` became deprecated
59- behaviour in version 2.4.1. Support for ``'auto'`` will be removed
56+ behaviour in version 2.4.1. Support for ``'auto'`` was removed
6057 in version 3.0.0.
6158"""
6259KEEP_FILE_OPEN_DEFAULT = False
@@ -102,7 +99,7 @@ def __init__(self, file_like, spec, mmap=True, keep_file_open=None):
10299
103100 .. deprecated:: 2.4.1
104101 ``keep_file_open='auto'`` is redundant with `False` and has
105- been deprecated. It will raise an error in nibabel 3.0.
102+ been deprecated. It raises an error as of nibabel 3.0.
106103
107104 Parameters
108105 ----------
@@ -239,14 +236,14 @@ def _should_keep_file_open(self, file_like, keep_file_open):
239236
240237 .. deprecated:: 2.4.1
241238 ``keep_file_open='auto'`` is redundant with `False` and has
242- been deprecated. It will be removed in nibabel 3.0.
239+ been deprecated. It raises an error as of nibabel 3.0.
243240
244241 Parameters
245242 ----------
246243
247244 file_like : object
248245 File-like object or filename, as passed to ``__init__``.
249- keep_file_open : { 'auto', True, False }
246+ keep_file_open : { True, False }
250247 Flag as passed to ``__init__``.
251248
252249 Returns
@@ -259,23 +256,17 @@ def _should_keep_file_open(self, file_like, keep_file_open):
259256 """
260257 if keep_file_open is None :
261258 keep_file_open = KEEP_FILE_OPEN_DEFAULT
262- if keep_file_open == 'auto' :
263- warnings .warn ("Setting nibabel.arrayproxy.KEEP_FILE_OPEN_DEFAULT to 'auto' is "
264- "deprecated and will become an error in v3.0." , DeprecationWarning )
265- if keep_file_open == 'auto' :
266- warnings .warn ("A value of 'auto' for keep_file_open is deprecated and will become an "
267- "error in v3.0. You probably want False." , DeprecationWarning )
259+ if keep_file_open not in (True , False ):
260+ raise ValueError ("nibabel.arrayproxy.KEEP_FILE_OPEN_DEFAULT must be boolean. "
261+ "Found: {}" .format (keep_file_open ))
268262 elif keep_file_open not in (True , False ):
269- raise ValueError ('keep_file_open should be one of {None, True, False}' )
263+ raise ValueError ('keep_file_open must be one of {None, True, False}' )
270264
271265 # file_like is a handle - keep_file_open is irrelevant
272266 if hasattr (file_like , 'read' ) and hasattr (file_like , 'seek' ):
273267 return False , False
274268 # if the file is a gzip file, and we have_indexed_gzip,
275269 have_igzip = openers .HAVE_INDEXED_GZIP and file_like .endswith ('.gz' )
276- # XXX Remove in v3.0
277- if keep_file_open == 'auto' :
278- return have_igzip , have_igzip
279270
280271 persist_opener = keep_file_open or have_igzip
281272 return keep_file_open , persist_opener
0 commit comments