-
Notifications
You must be signed in to change notification settings - Fork 51
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
Relative data file path printing #79
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d590ed4
Merge pull request #1 from mhe/master
tashrifbillah bfc7db9
relative data path
tashrifbillah 362612b
relative data path
tashrifbillah 106d2f7
relative path test
tashrifbillah ae816aa
using relative filename
tashrifbillah 524100f
wrapping lines at 120 characters
tashrifbillah fcb53fa
filename instead of file name
tashrifbillah d820b43
unused variable removal
tashrifbillah 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 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 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 | ||||
---|---|---|---|---|---|---|
|
@@ -93,7 +93,7 @@ def _format_field_value(value, field_type): | |||||
raise NRRDError('Invalid field type given: %s' % field_type) | ||||||
|
||||||
|
||||||
def write(filename, data, header={}, detached_header=False, custom_field_map=None, | ||||||
def write(filename, data, header={}, detached_header=False, relative_data_path=True, custom_field_map=None, | ||||||
compression_level = 9): | ||||||
"""Write :class:`numpy.ndarray` to NRRD file | ||||||
|
||||||
|
@@ -121,6 +121,9 @@ def write(filename, data, header={}, detached_header=False, custom_field_map=Non | |||||
Data to save to the NRRD file | ||||||
detached_header : :obj:`bool`, optional | ||||||
Whether the header and data should be saved in separate files. Defaults to :obj:`False` | ||||||
relative_data_path : :class:`bool` | ||||||
Whether the data file name in detached header is saved with a relative path or absolute path. | ||||||
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. Alright, rereading this now I agree with how it's set. Just one minor thing, I usually prefer the use of
Suggested change
|
||||||
This parameter is ignored if there is no detached header. Defaults to :obj:`True` | ||||||
custom_field_map : :class:`dict` (:class:`str`, :class:`str`), optional | ||||||
Dictionary used for parsing custom field types where the key is the custom field name and the value is a | ||||||
string identifying datatype for the custom field. | ||||||
|
@@ -183,12 +186,14 @@ def write(filename, data, header={}, detached_header=False, custom_field_map=Non | |||||
else: | ||||||
raise NRRDError('Invalid encoding specification while writing NRRD file: %s' % header['encoding']) | ||||||
|
||||||
header['data file'] = data_filename | ||||||
header['data file'] = os.path.basename(data_filename) \ | ||||||
if relative_data_path else os.path.abspath(data_filename) | ||||||
else: | ||||||
data_filename = header['data file'] | ||||||
elif filename.endswith('.nrrd') and detached_header: | ||||||
data_filename = filename | ||||||
header['data file'] = data_filename | ||||||
header['data file'] = os.path.basename(data_filename) \ | ||||||
if relative_data_path else os.path.abspath(data_filename) | ||||||
filename = '%s.nhdr' % os.path.splitext(filename)[0] | ||||||
else: | ||||||
# Write header & data as one file | ||||||
|
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.
Sorry, one small thing. Since you directly placed the string to be asserted, the
output_data_filename
variable is not used. Remove that pleaseSame for above.
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.
Will review your other PRs, but may take some time.