From 6fed655500754b6e519d70d3d84493b86c2dffcc Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 26 Jan 2020 10:17:27 +0100 Subject: [PATCH] fix for new style and test --- python/damask/table.py | 2 +- python/tests/test_Table.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/python/damask/table.py b/python/damask/table.py index 582089a54..3ef824c6d 100644 --- a/python/damask/table.py +++ b/python/damask/table.py @@ -74,7 +74,7 @@ class Table(): f.seek(0) try: - N_comment_lines,keyword = f.readline().split() + N_comment_lines,keyword = f.readline().strip().split(maxsplit=1) if keyword != 'header': raise TypeError else: diff --git a/python/tests/test_Table.py b/python/tests/test_Table.py index eed7b76b8..369a99efb 100644 --- a/python/tests/test_Table.py +++ b/python/tests/test_Table.py @@ -47,6 +47,13 @@ class TestTable: new = Table.from_ASCII(f) assert all(default.data==new.data) and default.shapes == new.shapes + def test_write_read_new_style(self,default,tmpdir): + with open(tmpdir.join('new_style.txt'),'w') as f: + default.to_ASCII(f,new=True) + with open(tmpdir.join('new_style.txt')) as f: + new = Table.from_ASCII(f) + assert all(default.data==new.data) and default.shapes == new.shapes + def test_read_ang_str(self,reference_dir): new = Table.from_ang(os.path.join(reference_dir,'simple.ang')) assert new.data.shape == (4,10) and \