Skip to content

Commit

Permalink
Addressing Issue27 (#28)
Browse files Browse the repository at this point in the history
* Bump version to 0.3.5

* Supporting sif_version 65564 without confidence

* Removed unecessary option
  • Loading branch information
fujiisoup authored Dec 3, 2023
1 parent 26d7c24 commit 80b41a9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions sif_parser/_sif_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def _to_string(c):
''' convert bytes to string. c: string or bytes'''
return c if not isinstance(c, bytes) else c.decode('utf-8')

def _read_string(fp, length = None):
def _read_string(fp, length=None):
'''Read a string of the given length. If no length is provided, the
length is read from the file.'''
if length is None:
Expand Down Expand Up @@ -121,7 +121,7 @@ def _open(fp):
elif info['SifVersion'] == 65558:
for _ in range(5):
fp.readline()
elif info['SifVersion'] == 65559:
elif info['SifVersion'] in [65559, 65564]:
for _ in range(8):
fp.readline() # Skip to Line 18
info['spectrograph'] = _to_string(fp.readline().split()[1])
Expand Down Expand Up @@ -165,7 +165,7 @@ def _open(fp):

fp.readline() # 13 newline or 6.5
fp.readline() # 13 newline or 6.5

info['FrameAxis'] = _read_string(fp) # Line 26 or 39
info['DataType'] = _read_string(fp)
info['ImageAxis'] = _read_string(fp)
Expand Down
2 changes: 1 addition & 1 deletion sif_parser/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@


__version_info__ = (0, 3, 4)
__version__ = "0.3.4" # pragma: no cover
__version__ = "0.3.5" # pragma: no cover
Binary file added testings/issue27/test.sif
Binary file not shown.
6 changes: 6 additions & 0 deletions testings/test_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
if os.path.exists(e):
spool_encoding_dirs += sorted([e + dd for dd in os.listdir(e) if not dd.startswith(".DS")], key=str.lower)

def test_issue27():
filename = THIS_DIR + '/issue27/test.sif'
with open(filename, 'rb') as f:
data, info = sif_parser.np_open(f)
assert np.sum(np.isnan(data)) == 0


@pytest.mark.parametrize('filename', filenames)
def test_open(filename):
Expand Down

0 comments on commit 80b41a9

Please sign in to comment.