Skip to content

Commit

Permalink
[impl]: Replace assertions with exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
haoyu-zc committed Sep 26, 2024
1 parent 9dfea76 commit ce103b2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libs/ccc/coef/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,8 @@ def ccc(
if x.ndim == 1 and (y is not None and y.ndim == 1):
# both x and y are 1d arrays
# TODO: remove assertions and raise exceptions
assert x.shape == y.shape, "x and y need to be of the same size"
if not x.shape == y.shape:
raise ValueError("x and y need to be of the same size")
n_objects = x.shape[0]
n_features = 2

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

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

Expand Down

0 comments on commit ce103b2

Please sign in to comment.