Skip to content

Make backend array functions callable from Triangle #1031

@genedan

Description

@genedan

Description

There are several calls to xp = self.get_array_module() throughout the library. xp results in numpy or sparse. xp then calls an array function to do something, e.g.,:

xp = self.get_array_module()
fill = (xp.nan_to_num(self.values) == 0) * (self * 0 + value)

This pattern appears frequently throughout the library. I think it may be possible to simplify the call to just:

fill = (self.nan_to_num(self.values) == 0) * (self * 0 + value)

Where the array function (in this case, nan_to_num()) is the one pertaining to the Triangle's backend, e.g., numpy.nan_to_num() or sparse.nan_to_num().

Calling Triangle.set_backend() will swap the array functions to be called from the appropriate backend module.

Is your feature request aligned with the scope of the package?

  • Yes, absolutely!
  • No, but it's still worth discussing.
  • N/A (this request is not a codebase enhancement).

Describe the solution you'd like, or your current workaround.

No response

Do you have any additional supporting notes?

No response

Would you be willing to contribute this ticket?

  • Yes, absolutely!
  • Yes, but I would like some help.
  • No.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority

    High

    Effort

    Medium

    Scope

    Codebase

    Projects

    Status
    Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions