-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle more buffer types & fix nplike mixing (#1769)
* fix: handle more buffer types, fix nplike mixing * test: add test for Jacobian computation * fix: don't regularise `NumpyArray`s Remove assert - NumpyArray-only layouts might have Numpy nplike * fix: use node parameters and identifiers * test: skip Jacobian test for now. * fix: restore `TypeError` * refactor: use `_errors` module directly .
- Loading branch information
Showing
2 changed files
with
64 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE | ||
|
||
import pytest | ||
|
||
import awkward as ak | ||
|
||
jax = pytest.importorskip("jax") | ||
jax.config.update("jax_platform_name", "cpu") | ||
jax.config.update("jax_enable_x64", True) | ||
|
||
ak.jax.register_and_check() | ||
|
||
|
||
@pytest.mark.skip("Jacobian support not implemented") | ||
def test(): | ||
array = ak.Array([[1, 2, 3], [4, 5, 6.0]]) | ||
|
||
def func(x): | ||
return x * 2 - 1 | ||
|
||
array_np = ak.to_numpy(array) | ||
jac_np = jax.jacfwd(func)(array_np) | ||
|
||
jac = jax.jacfwd(func)(array) | ||
assert jac.to_list() == jac_np.tolist() |