-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upcast array to solve njit failure (#3652)
* upcast array to solve njit failure * add tests and remove debug statements
- Loading branch information
1 parent
86d8bc5
commit e21d70f
Showing
2 changed files
with
54 additions
and
2 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,23 @@ | ||
import numpy as np | ||
|
||
from shap.links import identity | ||
from shap.utils._masked_model import _build_fixed_output | ||
|
||
|
||
def test__build_fixed_output(): | ||
"""GH3651""" | ||
num_varying_rows = np.array([1]) | ||
varying_rows = np.array([[True]]) | ||
batch_positions = np.array([0, 1]) | ||
averaged_outs = np.zeros((1, 10), dtype=np.float32) | ||
last_outs = np.zeros((1, 10), dtype=np.float32) | ||
outputs = np.random.rand(1, 10).astype(np.float16) | ||
_build_fixed_output(averaged_outs, | ||
last_outs, | ||
outputs, | ||
batch_positions, | ||
varying_rows, | ||
num_varying_rows, | ||
identity, | ||
None) | ||
assert np.allclose(averaged_outs, outputs, 1e-2) |