Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear AssertionError when providing points of wrong dimensions #74

Closed
MakisH opened this issue Dec 8, 2020 · 1 comment · Fixed by #9
Closed

Unclear AssertionError when providing points of wrong dimensions #74

MakisH opened this issue Dec 8, 2020 · 1 comment · Fixed by #9
Assignees

Comments

@MakisH
Copy link
Member

MakisH commented Dec 8, 2020

When providing e.g. an array of 2D points:

vertices = numpy.array([[0,0]])
vertex_ids = Interface.set_mesh_vertices(mesh_id, vertices)

to a 3D mesh:

<solver-interface dimensions="3" >

the python bindings will catch this, but throw only a generic error:

  File "mysolver.py", line 75, in main
    vertex_ids = Interface.set_mesh_vertices(mesh_id, vertices)
  File "precice.pyx", line 525, in precice.Interface.set_mesh_vertices
AssertionError

preCICE itself should already catch this (and it give a clear error), so this raises the question whether we really need this duplicate error checking.

I understand that there is probably a good for having this assertion here (I vaguely remember a long discussion about it), but we need then an informative error message.

I am using preCICE v2.1.1 and the python bindings v2.1.1.1.

@IshaanDesai IshaanDesai self-assigned this Dec 8, 2020
@IshaanDesai
Copy link
Member

The assertion hit indeed does not give a clear idea of what went wrong. Improved error messages for the python bindings is ongoing work here: #9 and will be completed in the near-future. This particular assertion will then provide a proper message stating what went wrong.

The philosophy followed for the python bindings is that whichever errors can be caught at the bindings API level should be caught. Some points in favour of this argumentation:

  • Since we can derive the shape of an array in python it is relevant to catch errors then and there as the user might provide arrays of incorrect dimensions
  • A user of preCICE who is writing a code in python would be more comfortable to have a pythonic error feedback

More discussion is welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants