cast to list, as the default backend numpy casts the bools to np.bool…#2590
cast to list, as the default backend numpy casts the bools to np.bool…#2590WolfgangWaltenberger wants to merge 1 commit intoscikit-hep:mainfrom
Conversation
…, which the pytorch backend may have troubles casting to torch.bool
|
@WolfgangWaltenberger I'm going to close this as this is a different problem with changes in recent versions of PyTorch that needs to be solved differently as part of Issue #2554. This should get addressed in a final patch release for the current series with parts of PR #2566. The simplest approach for now is to downgrade your versions of PyTorch. Feel free to comment on Issue #2554 with questions or follow up. We're also going to be deprecating the PyTorch backend in the near future, so if you're actively relying on it please share your needs over in Discussion #2470. (Aside: While PRs are appreciated, we need them to not be from your default branch on your fork as we can't rebase them without closing the PR, so please always use a feature branch for PRs.) |
fix: we are casting the numpy array to a list. that way the booleans get cast from np.bool to python's native bool. i am doing
this because my torch backend has problems casting np.bool to torch.bool:
Which happens for me at
File "/home/walten/.venvs/default/lib/python3.13/site-packages/pyhf/tensor/pytorch_backend.py", line 207, in astensor
return torch.as_tensor(tensor_in, dtype=dtype)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'numpy.bool' object cannot be interpreted as an integer
Feel free though to solve this weird casting issue differently. Why it seems to be a problem for me but not for you, eludes me.
Wolfgang