Skip to content

Operators should return results instead of modifying argument #856

Description

@david-zwicker

We currently have operators (not just differential operators, but also functions that set valid data and boundary conditions) that often expect an out argument, which is modified by the operator. This made a lot of sense when we only targeted numba, but this paradigm is not supported by torch or jax, so we need to change our approach. To avoid having different call-signatures depending on backend, it might be best to convert all operators such that they return their result. Examples include:

field_lap = laplace(field)
field_w_bc = set_bcs(field)
field_full = set_valid(field_valid)
field_valid = get_valid(field_full)

We can still (optionally) accept an out argument, which might be helpful for numba, but this should not be required.

Unfortunately, this change will likely break backward compatibility, but this might be necessary. The upside is that this approach is likely much easier to use for people new to the package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions