alan-turing-institute / PeriPy

Code base for PeriPy, a lightweight, open-source and high-performance package for peridynamic simulations written in Python - a collaboration between Exeter, Cambridge & Turing
MIT License
46 stars 14 forks source link

test_mesh_cython and test_mesh_cl failing #103

Closed mark-hobbs closed 3 years ago

mark-hobbs commented 3 years ago

Two tests are failing. I initially thought that this might be related to a recent edit to the .gitignore file (ignore .vtk file types) but this does not appear to be the case. I returned to the original code and the tests still fail. I have attached details below. @bb515 do you have any idea what might be causing these tests to fail? It isn't clear to me what these tests do.

FAILED peripy/test/test_regression.py::TestRegression::test_mesh_cython - AssertionError: assert [b'BINARY', b...x00\x00', ...] == [b'BINARY', b...x00\x00', ...]
FAILED peripy/test/test_regression.py::TestRegression::test_mesh_cl - AssertionError: assert [b'BINARY', b...x00\x00', ...] == [b'BINARY', b...x00\x00', ...]
E       AssertionError: assert [b'BINARY', b...x00\x00', ...] == [b'BINARY', b...x00\x00', ...]
E         At index 16 diff: b'CELLS 4225 12544' != b'CELLS 4224 16768'
E         Left contains 105 more items, first extra item: b'6\xe2\xeb\x1cC-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00?'
E         Use -v to get the full diff
bb515 commented 3 years ago

You can view the tests in peripy/test/

These tests are listed below. They make sure that the mesh is identical to the one that was given with the package.

The meshes are stored in "peripy/test/data" and you probably haven't changed anything in there, but if you put git ignore vtk then these meshes will not get pushed to the repo, so you can't use gitignore vtk. Instead, you could git ignore the individual files that you create when making a new example. This doesn't explain why its failing though so not sure about that.

I would recommend when making a new example, creating a new directory "example3" and just gitignoring that directory.

def test_mesh_cython(self, regression_cython, data_path, tmp_path):
        """Ensure mesh file is identical."""
        model, displacements, damage, *_ = regression_cython
        path = data_path

        mesh = tmp_path / "mesh.vtk"
        expected_mesh = path / "expected_mesh.vtk"
        model.write_mesh(mesh, damage, displacements)

        assert(
            mesh.read_bytes().split(b"\n")[2:] ==
            expected_mesh.read_bytes().split(b"\n")[2:]
            )

def test_mesh_cl(self, regression_cl, data_path, tmp_path):
        """Ensure mesh file is identical."""
        model, displacements, damage, *_ = regression_cl
        path = data_path

        mesh = tmp_path / "mesh.vtk"
        expected_mesh = path / "expected_mesh_cl.vtk"
        model.write_mesh(mesh, damage, displacements)

        assert(
            mesh.read_bytes().split(b"\n")[2:] ==
            expected_mesh.read_bytes().split(b"\n")[2:]
            )
bb515 commented 3 years ago

Fixed it. Reverted to Jim's original testing code @pytest.mark.skip(reason="Stalling" which skips the test on travis if it stalls like this.