floiseau / msh2xdmf

Converter from MSH mesh format to XDMF mesh format
GNU General Public License v3.0
19 stars 11 forks source link

test_conversion: meshio TypeError: cannot unpack non-iterable CellBlock #14

Open drew-parsons opened 2 years ago

drew-parsons commented 2 years ago

Recent changes to meshio now cause test_conversion.py to fail:

_________________________________________________________________________________________________ test_conversion _________________________________________________________________________________________________

    def test_conversion():
        """
        Test the conversion from msh to xdmf.
        """
        # Get the current directory
        current_dir = "{}".format(os.getcwd())
        # Run the conversion
>       msh2xdmf("multidomain.msh", dim=2, directory=current_dir)

test_conversion_here.py:14: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/msh2xdmf.py:28: in msh2xdmf
    export_domain(msh, dim, directory, prefix)
/usr/lib/python3/dist-packages/msh2xdmf.py:45: in export_domain
    data_array = [arr for (t, arr) in msh.cells if t == cell_type]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

.0 = <list_iterator object at 0x7f5a9ca5c280>

>   data_array = [arr for (t, arr) in msh.cells if t == cell_type]
E   TypeError: cannot unpack non-iterable CellBlock object

/usr/lib/python3/dist-packages/msh2xdmf.py:45: TypeError
============================================================================================= short test summary info =============================================================================================
FAILED test_conversion_here.py::test_conversion - TypeError: cannot unpack non-iterable CellBlock object
================================================================================================ 1 failed in 1.28s ================================================================================================

This is with meshio 5.3.0. The change might be related to https://github.com/nschloe/meshio/pull/1234 , which went into meshio 5.1.1

bragostin commented 2 years ago

I have it working again with these modifications: line 49 : data_array = [cell.data for cell in msh.cells if cell.type == cell_type] line 57 : cell_type=cell_type, line 109 : data_array = [cell.data for cell in msh.cells if cell.type == cell_type] line 117 : cell_type=cell_type,