From 6f79573140f9a3b601cc94e17e13576c68baab76 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 23 Aug 2020 11:05:56 +0200 Subject: [PATCH] more test coverage --- python/damask/_geom.py | 4 +-- .../tests/reference/Geom/clean_2_2_False.vtr | 25 +++++++++++++++++++ .../tests/reference/Geom/clean_2_2_True.vtr | 25 +++++++++++++++++++ .../tests/reference/Geom/clean_3_2_False.vtr | 25 +++++++++++++++++++ .../tests/reference/Geom/clean_3_2_True.vtr | 25 +++++++++++++++++++ .../tests/reference/Geom/clean_4_2_False.vtr | 25 +++++++++++++++++++ .../tests/reference/Geom/clean_4_2_True.vtr | 25 +++++++++++++++++++ python/tests/test_Geom.py | 8 ++++-- 8 files changed, 157 insertions(+), 5 deletions(-) create mode 100644 python/tests/reference/Geom/clean_2_2_False.vtr create mode 100644 python/tests/reference/Geom/clean_2_2_True.vtr create mode 100644 python/tests/reference/Geom/clean_3_2_False.vtr create mode 100644 python/tests/reference/Geom/clean_3_2_True.vtr create mode 100644 python/tests/reference/Geom/clean_4_2_False.vtr create mode 100644 python/tests/reference/Geom/clean_4_2_True.vtr diff --git a/python/damask/_geom.py b/python/damask/_geom.py index 722df2524..c8963b616 100644 --- a/python/damask/_geom.py +++ b/python/damask/_geom.py @@ -608,9 +608,7 @@ class Geom: """ valid = {'x','y','z'} - if not all(isinstance(d, str) for d in directions): - raise TypeError('Directions are not of type str.') - elif not set(directions).issubset(valid): + if not set(directions).issubset(valid): raise ValueError(f'Invalid direction {set(directions).difference(valid)} specified.') limits = [None,None] if reflect else [-2,0] diff --git a/python/tests/reference/Geom/clean_2_2_False.vtr b/python/tests/reference/Geom/clean_2_2_False.vtr new file mode 100644 index 000000000..c2ad86f43 --- /dev/null +++ b/python/tests/reference/Geom/clean_2_2_False.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAAOgAAAA==eF7t1CEOACAMBMHS/z8aXwNJSagYMe6y8jIislgNtTW9d9oD/PL6r6b3AAAAAAAAAAAA4MYGlRYLYA== + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/reference/Geom/clean_2_2_True.vtr b/python/tests/reference/Geom/clean_2_2_True.vtr new file mode 100644 index 000000000..b4d19ebcf --- /dev/null +++ b/python/tests/reference/Geom/clean_2_2_True.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAANwAAAA==eF7t1KERADAMA7Gk+w9dWpYCswiI+R66q6rDzmPa/kj3ALZK/2m6BwAAAAAAAAAAAJMLZrELTQ== + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/reference/Geom/clean_3_2_False.vtr b/python/tests/reference/Geom/clean_3_2_False.vtr new file mode 100644 index 000000000..c2ad86f43 --- /dev/null +++ b/python/tests/reference/Geom/clean_3_2_False.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAAOgAAAA==eF7t1CEOACAMBMHS/z8aXwNJSagYMe6y8jIislgNtTW9d9oD/PL6r6b3AAAAAAAAAAAA4MYGlRYLYA== + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/reference/Geom/clean_3_2_True.vtr b/python/tests/reference/Geom/clean_3_2_True.vtr new file mode 100644 index 000000000..b4d19ebcf --- /dev/null +++ b/python/tests/reference/Geom/clean_3_2_True.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAANwAAAA==eF7t1KERADAMA7Gk+w9dWpYCswiI+R66q6rDzmPa/kj3ALZK/2m6BwAAAAAAAAAAAJMLZrELTQ== + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/reference/Geom/clean_4_2_False.vtr b/python/tests/reference/Geom/clean_4_2_False.vtr new file mode 100644 index 000000000..7665bdde2 --- /dev/null +++ b/python/tests/reference/Geom/clean_4_2_False.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAANQAAAA==eF7t1CEOACAMBMGj/380Fk+TQjJi7MqtJHVYlypv9wB+0f2+7h4AAAAAAAAAAABM2HWwC1M= + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/reference/Geom/clean_4_2_True.vtr b/python/tests/reference/Geom/clean_4_2_True.vtr new file mode 100644 index 000000000..88a8643d9 --- /dev/null +++ b/python/tests/reference/Geom/clean_4_2_True.vtr @@ -0,0 +1,25 @@ + + + + + + + + + AQAAAACAAAAALQAAJAAAAA==eF7twwEJAAAMBKH7/qWXY6DgqqmqqqqqqqqqqqqqPnhyUwtB + + + + + AQAAAACAAACoAAAAVQAAAA==eF5jYICAWTNBYKU9hN5pb2IMAoeh/JP2EFUXoOKX7dPTQOAaVP6m/dkzIHAHqu4BVPwhVP1jqPwTqL5nUHUvoOpeQtW9hqp7A1X3Dqrugz0ASSZF3Q== + + + AQAAAACAAACYAAAAVgAAAA==eF5jYIAAmeOFQLTGHkLvsQ8Fg6NQ/hn7IjDjIlT8qr1F32MgugGVv2MPMeUBVN1D+8cQBVD1T+3BymSeQ/W9sF8FBq+g+t/Yg4Ut3kHN+WAPAAVdQE4= + + + AQAAAACAAABIAAAAIgAAAA==eF5jYEAGB+wh9AUofQNKP4DST6D0Cyj9Bkp/sAcAAU8I6Q== + + + + + diff --git a/python/tests/test_Geom.py b/python/tests/test_Geom.py index 0ac633152..479dd43fc 100644 --- a/python/tests/test_Geom.py +++ b/python/tests/test_Geom.py @@ -135,14 +135,18 @@ class TestGeom: if update: modified.to_file(reference) assert geom_equal(modified,Geom.from_file(reference)) + @pytest.mark.parametrize('directions',[(1,2,'y'),('a','b','x'),[1]]) + def test_mirror_invalid(self,default,directions): + with pytest.raises(ValueError): + default.mirror(directions) + @pytest.mark.parametrize('stencil',[1,2,3,4]) - @pytest.mark.parametrize('selection',[None,1]) + @pytest.mark.parametrize('selection',[None,1,2]) @pytest.mark.parametrize('periodic',[True,False]) def test_clean(self,update,reference_dir,stencil,selection,periodic): current = Geom.from_vtr((reference_dir/'clean').with_suffix('.vtr')) current.clean(stencil,None if selection is None else [selection],periodic) reference = reference_dir/f'clean_{stencil}_{selection}_{periodic}' - altered = stencil !=1 and selection is not None if update and stencil !=1: current.to_vtr(reference) for _ in range(10):