Skip to content

Commit c034713

Browse files
committed
fix: resolve pytest, pandas, sklearn warnings and rust compiler dead code warnings
1 parent acd650c commit c034713

6 files changed

Lines changed: 14 additions & 9 deletions

File tree

src/merge_generic.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,13 @@ fn should_break(
7272
}
7373

7474
/// Helper function to fill NaN values for floating point types
75+
#[allow(dead_code)]
7576
fn fill_nan_f64(arr: &Array1<f64>, fill_value: f64) -> Array1<f64> {
7677
arr.mapv(|x| if x.is_nan() { fill_value } else { x })
7778
}
7879

7980
/// Helper function to fill NaN values for integer types (no-op)
81+
#[allow(dead_code)]
8082
fn fill_nan_int<T: Num + Copy>(arr: &Array1<T>, _fill_value: T) -> Array1<T> {
8183
arr.clone() // Integers don't have NaN, so just return a copy
8284
}

toad/preprocessing/process.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ def process(self, data):
129129
if col == _ALL_SYMBOL_:
130130
col = None
131131

132-
r = g.apply(f, col = col)
132+
try:
133+
r = g.apply(f, col = col, include_groups = False)
134+
except TypeError:
135+
r = g.apply(f, col = col)
133136

134137
if isinstance(r, pd.Series):
135138
r = pd.DataFrame(r)

toad/stats.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,8 @@ def feature_bin_stats(df_bin,feature,target):
421421
table['total'] = table['good'] + table['bad']
422422
table['badrate'] = table['bad'] / table['total']
423423
table['prop'] = table['total'] / table['total'].sum()
424-
table['y_prop'] = table['good'] / table['good'].sum()
425-
table['n_prop'] = table['bad'] / table['bad'].sum()
424+
table['y_prop'] = table['bad'] / table['bad'].sum()
425+
table['n_prop'] = table['good'] / table['good'].sum()
426426
table['woe'] = table.apply(lambda x : WOE(x['y_prop'], x['n_prop']),axis=1)
427427
table['iv'] = table.apply(lambda x : (x['y_prop'] - x['n_prop']) * WOE(x['y_prop'], x['n_prop']), axis=1)
428428
return table

toad/stats_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def test_quality():
6262
assert result.loc['feature', 'unique'] == 500
6363

6464
def test_quality_iv_only():
65-
result = quality(df, 'target', iv_only = True)
66-
assert np.isnan(result.loc['feature', 'gini'])
65+
result = quality(df, 'target', indicators = ['iv'])
66+
assert 'gini' not in result.columns
6767

6868
def test_quality_with_merge():
6969
result = quality(df, 'target', n_bins = 5, method = 'chi')

toad/transform.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def fit_(self, X, y, **kwargs):
385385
gbdt = GradientBoostingClassifier(**kwargs)
386386
gbdt.fit(X, y)
387387

388-
X = gbdt.apply(X)
388+
X = gbdt.apply(X.values if hasattr(X, 'values') else X)
389389
X = X.reshape(-1, X.shape[1])
390390

391391
onehot = OneHotEncoder().fit(X)
@@ -405,7 +405,7 @@ def transform_(self, rules, X):
405405
Returns:
406406
array-like
407407
"""
408-
X = rules['gbdt'].apply(X)
408+
X = rules['gbdt'].apply(X.values if hasattr(X, 'values') else X)
409409
X = X.reshape(-1, X.shape[1])
410410
res = rules['onehot'].transform(X).toarray()
411411
return res

toad/utils/progress/progress_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from .progress import Progress
33

44

5-
class TestIterator:
5+
class MockIterator:
66
def __init__(self, size):
77
self._size = size
88

@@ -22,7 +22,7 @@ def test_progress_size():
2222
assert p.size == 9527
2323

2424
def test_iterator():
25-
ti = TestIterator(100)
25+
ti = MockIterator(100)
2626
p = Progress(ti)
2727
for i in p:
2828
sleep(0.01)

0 commit comments

Comments
 (0)