Skip to content

Brainpy array does not support "where" argument in division #453

Open
@CloudyDory

Description

@CloudyDory
  • Check for duplicate issues.
  • Provide a complete example of how to reproduce the bug, wrapped in triple backticks like this:
  • If applicable, include full error messages/tracebacks.

I am trying to implement the function in Brainpy: x / (1.0 - bm.exp(-x)). When x->0, the function has a theoretical limit of 1.0, but if we directly set x=0, the function will output NaN.

In Numpy, this can be handled by: np.divide(x, 1.0-np.exp(-x), out=np.ones_like(x), where=np.abs(x)>=1.0e-6).

However, in Brainpy, the similar expression does not work: bm.divide(x, 1.0-bm.exp(-x), out=bm.ones_like(x), where=bm.abs(x)>=1.0e-6). The error message is: TypeError: true_divide() got an unexpected keyword argument 'where'.

How can we deal with situations like this in Brainpy?

Metadata

Metadata

Assignees

No one assigned

    Labels

    brainpy.mathissue belongs to brainpy.math modulebugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions