Skip to content

Commit

Permalink
MAINT: Sparky files with mismatched size and seek_pos issue warning
Browse files Browse the repository at this point in the history
Previous behavior was to raise an IOError when a size mismatch was detected.
  • Loading branch information
jjhelmus committed Nov 26, 2014
1 parent a71136f commit cedf466
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions nmrglue/fileio/sparky.py
Expand Up @@ -17,6 +17,7 @@
import os
import struct
import datetime
from warnings import warn

import numpy as np

Expand Down Expand Up @@ -384,7 +385,7 @@ def read_2D(filename):

# check for file size mismatch
if seek_pos != dic["seek_pos"]:
raise IOError("Bad file size %s vs %s", (seek_pos, dic["seek_pos"]))
warn('Bad file size in header %s vs %s' % (seek_pos, dic['seek_pos']))

# read the axis headers...
for i in range(dic['naxis']):
Expand Down Expand Up @@ -442,7 +443,7 @@ def read_3D(filename):

# check for file size mismatch
if seek_pos != dic["seek_pos"]:
raise IOError("Bad file size %s vs %s", (seek_pos, dic["seek_pos"]))
warn('Bad file size in header %s vs %s' % (seek_pos, dic['seek_pos']))

# read the axis headers...
for i in range(dic['naxis']):
Expand Down Expand Up @@ -507,7 +508,7 @@ def read_lowmem_2D(filename):

# check for file size mismatch
if seek_pos != dic["seek_pos"]:
raise IOError("Bad file size %s vs %s", (seek_pos, dic["seek_pos"]))
warn('Bad file size in header %s vs %s' % (seek_pos, dic['seek_pos']))
return dic, data


Expand All @@ -523,7 +524,7 @@ def read_lowmem_3D(filename):

# check for file size mismatch
if seek_pos != dic["seek_pos"]:
raise IOError("Bad file size %s vs %s", (seek_pos, dic["seek_pos"]))
warn('Bad file size in header %s vs %s' % (seek_pos, dic['seek_pos']))

return dic, data

Expand Down

0 comments on commit cedf466

Please sign in to comment.