Skip to content

Commit 73afc8c

Browse files
committed
handling of block separation, even if -1 is used in header
1 parent dd5af6e commit 73afc8c

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

data/NX simulation output.uff

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ NX: Correlation
1616
-1
1717
-1
1818
2400
19-
13 7 +1 0
19+
13 7 -1 0
2020
Fem1
2121

2222
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

pyuff/pyuff.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,16 @@ def refresh(self):
186186
ind = data.find(b' -1', ind + 1)
187187
if ind == -1:
188188
break
189-
block_ind.append(ind)
189+
if ind+6 == data_len:
190+
block_ind.append(ind)
191+
# Check if the block is valid and ends with LF or CR
192+
elif ind+6 < data_len and data[ind+6] in [10, 13]:
193+
block_ind.append(ind)
194+
# Check the line continues with blanks up to character 80
195+
elif ind+80 < data_len and data[ind+6:ind+80] == \
196+
b' ':
197+
block_ind.append(ind)
198+
190199
block_ind = np.asarray(block_ind, dtype='int64')
191200

192201
# Constructs block indices of start and end values; each pair

tests/test_58.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,7 @@ def test_write_read_func_type_0():
288288

289289

290290
if __name__ == '__main__':
291-
test_read_write_read_given_data()
292-
test_write_read_func_type_0()
291+
test_fix_58b()
293292

294293
if __name__ == '__mains__':
295294
np.testing.run_module_suite()

0 commit comments

Comments
 (0)