Skip to content

Commit cd65af4

Browse files
committed
RF: Changed default keep_file_open value to 'auto', to make it a bit more general
1 parent 961f882 commit cd65af4

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

nibabel/analyze.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ def set_data_dtype(self, dtype):
934934

935935
@classmethod
936936
@kw_only_meth(1)
937-
def from_file_map(klass, file_map, mmap=True, keep_file_open='indexed'):
937+
def from_file_map(klass, file_map, mmap=True, keep_file_open='auto'):
938938
''' class method to create image from mapping in `file_map ``
939939
940940
Parameters
@@ -950,13 +950,13 @@ def from_file_map(klass, file_map, mmap=True, keep_file_open='indexed'):
950950
`mmap` value of True gives the same behavior as ``mmap='c'``. If
951951
image data file cannot be memory-mapped, ignore `mmap` value and
952952
read array from file.
953-
keep_file_open : { 'indexed', True, False }, optional, keyword only
953+
keep_file_open : { 'auto', True, False }, optional, keyword only
954954
`keep_file_open` controls whether a new file handle is created
955955
every time the image is accessed, or a single file handle is
956956
created and used for the lifetime of this ``ArrayProxy``. If
957957
``True``, a single file handle is created and used. If ``False``,
958958
a new file handle is created every time the image is accessed. If
959-
``'indexed'`` (the default), and the optional ``indexed_gzip``
959+
``'auto'`` (the default), and the optional ``indexed_gzip``
960960
dependency is present, a single file handle is created and
961961
persisted. If ``indexed_gzip`` is not available, behaviour is the
962962
same as if ``keep_file_open is False``. If ``file_like`` is an
@@ -988,7 +988,7 @@ def from_file_map(klass, file_map, mmap=True, keep_file_open='indexed'):
988988

989989
@classmethod
990990
@kw_only_meth(1)
991-
def from_filename(klass, filename, mmap=True, keep_file_open='indexed'):
991+
def from_filename(klass, filename, mmap=True, keep_file_open='auto'):
992992
''' class method to create image from filename `filename`
993993
994994
Parameters
@@ -1002,13 +1002,13 @@ def from_filename(klass, filename, mmap=True, keep_file_open='indexed'):
10021002
`mmap` value of True gives the same behavior as ``mmap='c'``. If
10031003
image data file cannot be memory-mapped, ignore `mmap` value and
10041004
read array from file.
1005-
keep_file_open : { 'indexed', True, False }, optional, keyword only
1005+
keep_file_open : { 'auto', True, False }, optional, keyword only
10061006
`keep_file_open` controls whether a new file handle is created
10071007
every time the image is accessed, or a single file handle is
10081008
created and used for the lifetime of this ``ArrayProxy``. If
10091009
``True``, a single file handle is created and used. If ``False``,
10101010
a new file handle is created every time the image is accessed. If
1011-
``'indexed'`` (the default), and the optional ``indexed_gzip``
1011+
``'auto'`` (the default), and the optional ``indexed_gzip``
10121012
dependency is present, a single file handle is created and
10131013
persisted. If ``indexed_gzip`` is not available, behaviour is the
10141014
same as if ``keep_file_open is False``. If ``file_like`` is an

nibabel/arrayproxy.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class ArrayProxy(object):
7272
_header = None
7373

7474
@kw_only_meth(2)
75-
def __init__(self, file_like, spec, mmap=True, keep_file_open='indexed'):
75+
def __init__(self, file_like, spec, mmap=True, keep_file_open='auto'):
7676
"""Initialize array proxy instance
7777
7878
Parameters
@@ -102,13 +102,13 @@ def __init__(self, file_like, spec, mmap=True, keep_file_open='indexed'):
102102
True gives the same behavior as ``mmap='c'``. If `file_like`
103103
cannot be memory-mapped, ignore `mmap` value and read array from
104104
file.
105-
keep_file_open : { 'indexed', True, False }, optional, keyword only
105+
keep_file_open : { 'auto', True, False }, optional, keyword only
106106
`keep_file_open` controls whether a new file handle is created
107107
every time the image is accessed, or a single file handle is
108108
created and used for the lifetime of this ``ArrayProxy``. If
109109
``True``, a single file handle is created and used. If ``False``,
110110
a new file handle is created every time the image is accessed. If
111-
``'indexed'`` (the default), and the optional ``indexed_gzip``
111+
``'auto'`` (the default), and the optional ``indexed_gzip``
112112
dependency is present, a single file handle is created and
113113
persisted. If ``indexed_gzip`` is not available, behaviour is the
114114
same as if ``keep_file_open is False``. If ``file_like`` is an
@@ -177,7 +177,7 @@ def _should_keep_file_open(self, file_like, keep_file_open):
177177
178178
file_like : object
179179
File-like object or filename, as passed to ``__init__``.
180-
keep_file_open : { 'indexed', True, False }
180+
keep_file_open : { 'auto', True, False }
181181
Flag as passed to ``__init__``.
182182
183183
Returns
@@ -191,7 +191,7 @@ def _should_keep_file_open(self, file_like, keep_file_open):
191191
if hasattr(file_like, 'read') and hasattr(file_like, 'seek'):
192192
return False
193193
# if keep_file_open is True/False, we do what the user wants us to do
194-
if keep_file_open != 'indexed':
194+
if keep_file_open != 'auto':
195195
return bool(keep_file_open)
196196
# Otherwise, if file_like is gzipped, and we have_indexed_gzip, we set
197197
# keep_file_open to True, else we set it to False

nibabel/spm99analyze.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class Spm99AnalyzeImage(analyze.AnalyzeImage):
245245

246246
@classmethod
247247
@kw_only_meth(1)
248-
def from_file_map(klass, file_map, mmap=True, keep_file_open='indexed'):
248+
def from_file_map(klass, file_map, mmap=True, keep_file_open='auto'):
249249
'''class method to create image from mapping in `file_map ``
250250
251251
Parameters
@@ -261,13 +261,13 @@ def from_file_map(klass, file_map, mmap=True, keep_file_open='indexed'):
261261
`mmap` value of True gives the same behavior as ``mmap='c'``. If
262262
image data file cannot be memory-mapped, ignore `mmap` value and
263263
read array from file.
264-
keep_file_open : { 'indexed', True, False }, optional, keyword only
264+
keep_file_open : { 'auto', True, False }, optional, keyword only
265265
`keep_file_open` controls whether a new file handle is created
266266
every time the image is accessed, or a single file handle is
267267
created and used for the lifetime of this ``ArrayProxy``. If
268268
``True``, a single file handle is created and used. If ``False``,
269269
a new file handle is created every time the image is accessed. If
270-
``'indexed'`` (the default), and the optional ``indexed_gzip``
270+
``'auto'`` (the default), and the optional ``indexed_gzip``
271271
dependency is present, a single file handle is created and
272272
persisted. If ``indexed_gzip`` is not available, behaviour is the
273273
same as if ``keep_file_open is False``. If ``file_like`` is an

0 commit comments

Comments
 (0)