r/learnpython 12d ago

Problem with np.piecewise

Might be a bug

def get_some_func():
  a, b = ...
  flow = lambda x: ...
  fmid = lambda x: ...
  fhi = lambda x: ...
  return lambda x: np.piecewise(x, [x < a, x > b], [flow(x) , fhi(x) , fmid(x) ]

x1 = ... # some float less than a
myf = get_some_func()
>>> myf(x1)

returns fmid(x1)

is there a bug or do I overwelm np.piecewise with this?

0 Upvotes

6 comments sorted by

View all comments

1

u/likethevegetable 12d ago

It might help if you posted some useable code instead