|
38 | 38 | from vtk_utils.compare_grids import compare_grids |
39 | 39 |
|
40 | 40 | from meshpy.core.conf import mpy |
| 41 | +from meshpy.core.mesh import Mesh |
41 | 42 | from meshpy.four_c.input_file import InputFile |
42 | 43 | from meshpy.four_c.yaml_dumper import MeshPyDumper as _MeshPyDumper |
43 | 44 | from meshpy.utils.environment import fourcipp_is_available |
@@ -274,8 +275,8 @@ def assert_results_equal(get_string, tmp_path, current_test_name) -> Callable: |
274 | 275 | """ |
275 | 276 |
|
276 | 277 | def _assert_results_equal( |
277 | | - reference: Union[Path, str, dict], |
278 | | - result: Union[Path, str, dict, InputFile], |
| 278 | + reference: Union[Path, str, dict, InputFile, Mesh], |
| 279 | + result: Union[Path, str, dict, InputFile, Mesh], |
279 | 280 | rtol: Optional[float] = None, |
280 | 281 | atol: Optional[float] = None, |
281 | 282 | input_file_kwargs: dict = {"add_header_information": False, "check_nox": False}, |
@@ -331,10 +332,20 @@ def get_dictionary(data) -> dict: |
331 | 332 | compare_dicts(reference_dict, result_dict, rtol=rtol, atol=atol) |
332 | 333 | return |
333 | 334 |
|
334 | | - if isinstance(reference, InputFile) or isinstance(result, InputFile): |
| 335 | + if isinstance(reference, (InputFile, Mesh)) or isinstance( |
| 336 | + result, (InputFile, Mesh) |
| 337 | + ): |
335 | 338 |
|
336 | 339 | def get_dictionary(data) -> dict: |
337 | 340 | """Get the dictionary representation of the data object.""" |
| 341 | + |
| 342 | + # Internally convert Mesh to InputFile to allow for simple comparison via dictionary |
| 343 | + # TODO this should be improved in the future |
| 344 | + if isinstance(data, Mesh): |
| 345 | + input_file = InputFile() |
| 346 | + input_file.add(data) |
| 347 | + data = input_file |
| 348 | + |
338 | 349 | if isinstance(data, InputFile): |
339 | 350 | if fourcipp_is_available(): |
340 | 351 | raise ValueError( |
|
0 commit comments