-
Notifications
You must be signed in to change notification settings - Fork 262
ENH: Take advantage of IndexedGzipFile drop_handles flag #614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
effigies
merged 12 commits into
nipy:master
from
pauldmccarthy:rf/deprecate_keep_file_open
Jun 4, 2018
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d67c7f2
RF: ArrayProxy.KEEP_FILE_OPEN default value changed to 'auto'. Opener
pauldmccarthy db6c6af
TEST: Update ImageOpener/ArrayProxy unit tests
pauldmccarthy 4c850cb
RF,STY: Make sure that non-gzip file handles are dropped when keep_fi…
pauldmccarthy 46632d6
TEST: Make sure non-gzip file handles are dropped when keep_file_open ==
pauldmccarthy b5111b5
RF: arrayproxy imports openers module, rather than importing individu…
pauldmccarthy b4db866
TEST: Change unit test arrayproxy mocks - no longer necessary.
pauldmccarthy 854d722
RF: Make minimum required indexed_gzip version 0.7.
pauldmccarthy 3a13871
TEST: Further adjustment to arrayproxy benchmark
pauldmccarthy a65cfd2
TEST,STY: Fixes to opener tests, unused import in benchmark.
pauldmccarthy d2972ce
RF: Always use indexed_gzip for read access to gz files
pauldmccarthy d5ad97a
TEST: Updated to expect indexed_gzip if present
pauldmccarthy e96d71c
RF: keep_file_open == 'auto' now causes file handles to be kept open if
pauldmccarthy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ | |
""" | ||
|
||
from timeit import timeit | ||
import contextlib | ||
import gc | ||
import itertools as it | ||
import numpy as np | ||
|
@@ -51,24 +50,14 @@ | |
('?', '?', '?', ':'), | ||
] | ||
|
||
KEEP_OPENS = [False, True] | ||
KEEP_OPENS = [False, True, 'auto'] | ||
|
||
if HAVE_INDEXED_GZIP: | ||
HAVE_IGZIP = [False, True] | ||
else: | ||
HAVE_IGZIP = [False] | ||
|
||
|
||
@contextlib.contextmanager | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can now remove |
||
def patch_indexed_gzip(have_igzip): | ||
|
||
atts = ['nibabel.openers.HAVE_INDEXED_GZIP', | ||
'nibabel.arrayproxy.HAVE_INDEXED_GZIP'] | ||
|
||
with mock.patch(atts[0], have_igzip), mock.patch(atts[1], have_igzip): | ||
yield | ||
|
||
|
||
def bench_arrayproxy_slicing(): | ||
|
||
print_git_title('\nArrayProxy gzip slicing') | ||
|
@@ -154,14 +143,15 @@ def fmt_sliceobj(sliceobj): | |
# load uncompressed and compressed versions of the image | ||
img = nib.load(testfile, keep_file_open=keep_open) | ||
|
||
with patch_indexed_gzip(have_igzip): | ||
with mock.patch('nibabel.openers.HAVE_INDEXED_GZIP', have_igzip): | ||
imggz = nib.load(testfilegz, keep_file_open=keep_open) | ||
|
||
def basefunc(): | ||
img.dataobj[fix_sliceobj(sliceobj)] | ||
|
||
def testfunc(): | ||
with patch_indexed_gzip(have_igzip): | ||
with mock.patch('nibabel.openers.HAVE_INDEXED_GZIP', | ||
have_igzip): | ||
imggz.dataobj[fix_sliceobj(sliceobj)] | ||
|
||
# make sure nothing is floating around from the previous test | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
#NOQA
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style warning without it -
BytesIO
only gets used ineval
ed strings, so the style checker doesn't pick it up as being used.