Skip to content

Usability: Calling write/read_block functions with float data #79

@BenjaminRodenberg

Description

@BenjaminRodenberg

A user just ran into the following error:

Traceback (most recent call last):
  File "/home/benjamin/python-bindings/test/test_bindings_module.py", line 198, in test_read_write_block_scalar_data_single_float
    solver_interface.write_block_scalar_data(1, 1, write_data)
  File "cyprecice/cyprecice.pyx", line 954, in cyprecice.Interface.write_block_scalar_data
    if len(values) > 0:
TypeError: object of type 'int' has no len()

I was able to reproduce this behavior (will push the branch in a moment) by providing a single float as write_data to write_block_scalar_data.

Main question

Is this wrong API usage? I think the C++ preCICE API would not even compile with this kind of input. What do we want to do in the python world? The code obviously runs, but the error message is not helpful.

Possible Solutions

Depending on the answer to the question above:

  • Do we want to raise an error, because it is wrong API usage?
  • Do we want to raise a warning, if we that the user is using the API in the wrong way and pass the arguments to write_scalar_data?
  • Do we want to call the "right" function automatically depending on user input? Maybe completely entirely drop the "block" vs. "non-block", "scalar" vs. "vector" interface and call the right function depending on user input (just read_data and write_data)? We can implement this in a non-breaking fashion. This is the most pythonic, but also most radical solution, since it really deviates from the C++ API. Maybe this is a good "experimental" feature?

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions