Skip to content

Commit 287534e

Browse files
committed
fixed errors from precommit hooks, mainly flake8
flake8 was giving incorrect compare types on some files. "do not compare types. Use is, is not, or isinstance() instead."
1 parent ffb39d0 commit 287534e

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

data/catalog/_data_main/process_data/process_utils_data.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ def get_one_hot_encoding(in_arr):
2222
output: m (ndarray): one-hot encoded matrix
2323
d (dict): also returns a dictionary original_val -> column in encoded matrix
2424
"""
25+
valid_types = (int, np.int64, float, np.float64)
2526

2627
for k in in_arr:
27-
if (
28-
str(type(k)) != "<type 'numpy.float64'>"
29-
and type(k) != int
30-
and type(k) != np.int64
31-
):
28+
# if (
29+
# str(type(k)) != "<type 'numpy.float64'>"
30+
# and type(k) != int
31+
# and type(k) != np.int64
32+
# ):
33+
if not isinstance(k, valid_types):
3234
print(str(type(k)))
3335
print("************* ERROR: Input arr does not have integer types")
3436
return None

methods/catalog/focus/model.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ def _filter_hinge_loss(n_class, mask_vector, features, sigma, temperature, model
4646
filtered_input = tf.boolean_mask(features, mask_vector)
4747

4848
# if sigma or temperature are not scalars
49-
if type(sigma) != float or type(sigma) != int:
49+
if not isinstance(
50+
sigma, (float, int)
51+
): # type(sigma) != float or type(sigma) != int:
5052
sigma = tf.boolean_mask(sigma, mask_vector)
51-
if type(temperature) != float or type(temperature) != int:
53+
if not isinstance(
54+
temperature, (float, int)
55+
): # type(temperature) != float or type(temperature) != int:
5256
temperature = tf.boolean_mask(temperature, mask_vector)
5357

5458
# compute loss

methods/catalog/larr/model.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ def get_counterfactuals(self, factuals: pd.DataFrame) -> pd.DataFrame:
206206
"The model did not predict any failures in the original training data. It cannot search for the Lambda parameter"
207207
)
208208

209-
recourse_needed_X_train = df_train_processed.iloc[np.where(preds_gpu_probs == 0)]
209+
recourse_needed_X_train = df_train_processed.iloc[
210+
np.where(preds_gpu_probs == 0)
211+
]
210212
# recourse_needed_X_train = df_train_processed.values[:5]
211213

212214
# first choose the optimal lambda value

0 commit comments

Comments
 (0)