Skip to content

Commit fd1cb1c

Browse files
committed
[impl]: Replace assertions with exceptions
1 parent 9dfea76 commit fd1cb1c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

libs/ccc/coef/impl.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,8 @@ def ccc(
623623
X_numerical_type = None
624624
if x.ndim == 1 and (y is not None and y.ndim == 1):
625625
# both x and y are 1d arrays
626-
# TODO: remove assertions and raise exceptions
627-
assert x.shape == y.shape, "x and y need to be of the same size"
626+
if not x.shape == y.shape:
627+
raise ValueError("x and y need to be of the same size")
628628
n_objects = x.shape[0]
629629
n_features = 2
630630

@@ -640,10 +640,9 @@ def ccc(
640640
# plus we have the features data type (numerical, categorical, etc)
641641

642642
if isinstance(x, np.ndarray):
643-
assert get_feature_type_and_encode(x[0, :])[1], (
644-
"If data is a 2d numpy array, it has to be numerical. Use pandas.DataFrame if "
645-
"you need to mix features with different data types"
646-
)
643+
if not get_feature_type_and_encode(x[0, :])[1]:
644+
raise ValueError("If data is a 2d numpy array, it has to be numerical. Use pandas.DataFrame if "
645+
"you need to mix features with different data types")
647646
n_objects = x.shape[1]
648647
n_features = x.shape[0]
649648

0 commit comments

Comments
 (0)