Skip to content

Commit c94ebab

Browse files
authored
FIX: Remove breaking instance of ragged array (#3064)
* Remove breaking instance of ragged array * Update changelog
1 parent dd63adb commit c94ebab

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ into the main shap repository. PRs from this origin are labelled here as `fork#1
6666
[#3028](https://github.com/slundberg/shap/pull/3028),
6767
[#3029](https://github.com/slundberg/shap/pull/3029) and
6868
[#3031](https://github.com/slundberg/shap/pull/3031) by @connortann).
69+
- Fixed creation of ragged arrays in `shap.explainers.Exact`
70+
([#3064](https://github.com/slundberg/shap/pull/3064) by @connortann).
6971

7072
### Changed
7173

shap/explainers/_exact.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,10 @@ def partition_masks(partition_tree):
286286
inds_list0[i] = inverse_order[inds_list0[i]]
287287
inds_list1[i] = inverse_order[inds_list1[i]]
288288

289-
return all_masks[order], np.array([[np.array(on), np.array(off)] for on,off in inds_lists])
289+
# Care: inds_lists have different lengths, so partition_masks_inds is a "ragged" array. See GH #3063
290+
partition_masks = all_masks[order]
291+
partition_masks_inds = [[np.array(on), np.array(off)] for on, off in inds_lists]
292+
return partition_masks, partition_masks_inds
290293

291294
# TODO: this should be a jit function... which would require preallocating the inds_lists (sizes are 2**depth of that ind)
292295
# TODO: we could also probable avoid making the masks at all and just record the deltas if we want...

0 commit comments

Comments
 (0)