Skip to content

Commit 29dec52

Browse files
committed
move the handling for contiguous C data into unify_columns
1 parent 9639803 commit 29dec52

5 files changed

Lines changed: 2 additions & 23 deletions

File tree

python/interpret-core/interpret/glassbox/_ebm/_bin.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ def eval_terms(X, n_samples, feature_names_in, feature_types_in, bins, term_feat
6464
# TODO: we could pass out a bool array instead of objects for this function only
6565
bad = bad != _none_ndarray
6666

67-
if not X_col.flags.c_contiguous:
68-
# we requrested this feature, so at some point we're going to call discretize,
69-
# which requires contiguous memory
70-
X_col = X_col.copy()
71-
7267
for requirements in all_requirements:
7368
term_idx = requirements[-1]
7469
feature_idxs = term_features[term_idx]

python/interpret-core/interpret/glassbox/_ebm/_ebm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ def fit(self, X, y, sample_weight=None, bags=None, init_score=None):
873873
msg = "A value in bags is outside the valid range -128 to 127"
874874
_log.error(msg)
875875
raise ValueError(msg)
876-
bag = bag.astype(np.int8, copy=not bag.flags.c_contiguous)
876+
bag = bag.astype(np.int8, "C", copy=False)
877877

878878
rngs.append(bagged_rng)
879879
internal_bags.append(bag)

python/interpret-core/interpret/utils/_clean_x.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ def _process_continuous(X_col, nonmissings):
691691
# called under: fit or predict
692692

693693
if issubclass(X_col.dtype.type, np.floating):
694-
X_col = X_col.astype(dtype=np.float64, copy=False)
694+
X_col = X_col.astype(np.float64, "C", copy=False)
695695
return X_col, None
696696
if issubclass(X_col.dtype.type, np.integer) or issubclass(
697697
X_col.dtype.type, np.bool_

python/interpret-core/interpret/utils/_compressed_dataset.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ def bin_native(
6666
else:
6767
# continuous feature
6868

69-
if not X_col.flags.c_contiguous:
70-
# X_col could be a slice that has a stride. We need contiguous for caling into C
71-
X_col = X_col.copy()
72-
7369
X_col = native.discretize(X_col, feature_bins)
7470
n_bins = len(feature_bins) + 3
7571

@@ -115,10 +111,6 @@ def bin_native(
115111
else:
116112
# continuous feature
117113

118-
if not X_col.flags.c_contiguous:
119-
# X_col could be a slice that has a stride. We need contiguous for caling into C
120-
X_col = X_col.copy()
121-
122114
X_col = native.discretize(X_col, feature_bins)
123115
n_bins = len(feature_bins) + 3
124116

python/interpret-core/interpret/utils/_preprocessor.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,6 @@ def fit(self, X, y=None, sample_weight=None):
302302
_log.error(msg)
303303
raise ValueError(msg)
304304

305-
if not X_col.flags.c_contiguous:
306-
# X_col could be a slice that has a stride. We need contiguous for caling into C
307-
X_col = X_col.copy()
308-
309305
if self.binning == "private":
310306
if np.isnan(X_col).any():
311307
msg = "missing values in X not supported for private binning"
@@ -548,10 +544,6 @@ def transform(self, X):
548544
else:
549545
# continuous feature
550546

551-
if not X_col.flags.c_contiguous:
552-
# X_col could be a slice that has a stride. We need contiguous for caling into C
553-
X_col = X_col.copy()
554-
555547
X_col = native.discretize(X_col, bins)
556548

557549
if bad is not None:

0 commit comments

Comments
 (0)