Skip to content

BF+TST: fix XML output from in-memory Gifti array #470

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
merged 8 commits into from
Aug 8, 2016

Conversation

matthew-brett
Copy link
Member

GiftiDataArrays created in memory (rather than loaded from disk) had
ExternalFileOffset attribute value as an integer, but for valid XML, the
values have to be strings.

Closes gh-469.

GiftiDataArrays created in memory (rather than loaded from disk) had
ExternalFileOffset attribute value as an integer, but for valid XML, the
values have to be strings.

Closes nipygh-469.
@matthew-brett matthew-brett force-pushed the gifti-serialization-bug branch from 5e6af2f to 5f632fe Compare August 3, 2016 00:40
@coveralls
Copy link

coveralls commented Aug 3, 2016

Coverage Status

Coverage increased (+0.007%) to 96.224% when pulling 5f632fe on matthew-brett:gifti-serialization-bug into a4724b7 on nipy:master.

@coveralls
Copy link

coveralls commented Aug 3, 2016

Coverage Status

Coverage increased (+0.007%) to 96.224% when pulling 5f632fe on matthew-brett:gifti-serialization-bug into a4724b7 on nipy:master.

@codecov-io
Copy link

codecov-io commented Aug 3, 2016

Current coverage is 94.26% (diff: 100%)

Merging #470 into master will increase coverage by 0.02%

@@             master       #470   diff @@
==========================================
  Files           160        160          
  Lines         21197      21261    +64   
  Methods           0          0          
  Messages          0          0          
  Branches       2266       2272     +6   
==========================================
+ Hits          19975      20041    +66   
+ Misses          802        801     -1   
+ Partials        420        419     -1   

Powered by Codecov. Last update a4724b7...5dad677

@yarikoptic
Copy link
Member

FWIW confirming that it does resolve #469 for PyMVPA. Thanks!

@matthew-brett
Copy link
Member Author

Any comments here?

@effigies
Copy link
Member

effigies commented Aug 6, 2016

Definitely fixes the bug, but given that GiftiDataArray.ext_offset is defined in the docstring to be an int, I'd think this line should be coercing to an int.

Maybe we should have a test to check types on parsed files?

@matthew-brett
Copy link
Member Author

Chris - yes, I think you're right. Any ideas for a good general (or not general) way to check loaded attribute types?

@effigies
Copy link
Member

effigies commented Aug 6, 2016

Simplest thing I can think of (in about 30 seconds) that isn't too class-specific is something on the order of:

default = klass()
loaded = klass.read_from_file(fname)
for attr in dir(default):
    assert isinstance(getattr(loaded, attr), type(getattr(default, attr)))

Can probably imagine some ways for this to fail, but the other options I can think of would be a lot of work.

@yarikoptic
Copy link
Member

default = klass()
loaded = klass.read_from_file(fname)
for attr in dir(default):
assert isinstance(getattr(loaded, attr), type(getattr(default, attr)))
Can probably imagine some ways for this to fail, but the other options I
can think of would be a lot of work.

why it shouldn't match type exactly but allow for subclassing?

Yaroslav O. Halchenko
Center for Open Neuroscience http://centerforopenneuroscience.org
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834 Fax: +1 (603) 646-1419
WWW: http://www.linkedin.com/in/yarik

@matthew-brett
Copy link
Member Author

Chris - looks like a reasonable check to me - any interest in a quick PR?

@effigies
Copy link
Member

effigies commented Aug 6, 2016

PR against your branch, Matthew. It'll fail the Python 2 checks as noted over there.

Add / use helper function for converting string to integer, where empty
string maps to 0.
Specify all default GIFTI strings as unicode.
@coveralls
Copy link

coveralls commented Aug 6, 2016

Coverage Status

Coverage increased (+0.02%) to 96.233% when pulling 61c9005 on matthew-brett:gifti-serialization-bug into a4724b7 on nipy:master.

continue
loadedtype = type(getattr(loaded, attr))
assert_equal(loadedtype, defaulttype,
"Type mismatch for attribute: {} ({!s} != {!s})".format(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, forgot about 2.6:

"Type mismatch for attribute: {0} ({1!s} != {2!s})".format(

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, now I'm trying to debug the errors on Python 2.6, I think it's time for 2.6 to go. It's getting really hard to set up testing on 2.6. OK with you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally fine with that.

Goodbye old friend.  Thanks for all the fish.
Note where requirements should be updated.

Update minimum numpy version.

Note new minimum Python version (2.7).
@coveralls
Copy link

coveralls commented Aug 6, 2016

Coverage Status

Coverage increased (+0.02%) to 96.233% when pulling 5dad677 on matthew-brett:gifti-serialization-bug into a4724b7 on nipy:master.

@matthew-brett
Copy link
Member Author

Ok - thanks for the feedback - it's certainly a better PR now. Any more comments?

@effigies
Copy link
Member

effigies commented Aug 6, 2016

LGTM.

# Check these against
# nibabel/info.py
# .travis.yml
# doc/source/installation.rst
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, what do you think about specifying minimal versioned requirements in setup.py, and then allow for structured optional dependencies (see eg how we have it in datalad)? See eg https://caremad.io/2013/07/setup-vs-requirement/ for the point

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR but just saw these notes inspired by duplication, so decided to ask ;-)

@matthew-brett
Copy link
Member Author

OK to merge this one?

@effigies
Copy link
Member

effigies commented Aug 8, 2016

👍

@matthew-brett matthew-brett merged commit e37cb5d into nipy:master Aug 8, 2016
@matthew-brett matthew-brett deleted the gifti-serialization-bug branch August 8, 2016 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants