Skip to content

Commit

Permalink
Merge pull request #37 from kamo-naoyuki/fix_35
Browse files Browse the repository at this point in the history
fix #35:   kaldiio/matio.py
  • Loading branch information
nttcslab-sp-admin authored Aug 20, 2019
2 parents a909b3d + edd9b6f commit 895c3f1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions kaldiio/matio.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from functools import partial
from io import BytesIO
from io import StringIO
import os
import re
import struct
import sys
Expand Down Expand Up @@ -478,7 +477,7 @@ def read_ascii_mat(fd, return_size=False):
except UnicodeDecodeError:
raise ValueError('File format is wrong?')
size += 1
if char == ' ' or char == os.linesep:
if char == ' ' or char == '\n':
continue
elif char == '[':
hasparent = True
Expand All @@ -503,15 +502,15 @@ def read_ascii_mat(fd, return_size=False):
else:
char = fd.read(1).decode(py2_default_encoding)
size += 1
assert char == os.linesep or char == ''
assert char == '\n' or char == ''
break
elif char == os.linesep:
elif char == '\n':
ndmin = 2
elif char == '':
raise ValueError(
'There are no corresponding bracket \']\' with \'[\'')
else:
if char == os.linesep or char == '':
if char == '\n' or char == '':
break
string.append(char)
string = ''.join(string)
Expand Down Expand Up @@ -613,7 +612,7 @@ def save_ark(ark, array_dict, scp=None, append=False, text=False,
with open_or_fd(scp, mode) as fd:
for key, position in zip(array_dict, pos_list):
fd.write(key + u' ' + name + ':' +
str(position + offset) + os.linesep)
str(position + offset) + '\n')


def save_mat(fname, array, endian='<', compression_method=None):
Expand Down

0 comments on commit 895c3f1

Please sign in to comment.