@@ -155,9 +155,9 @@ def _preprocess_inputs(X: ArrayLike, Y: ArrayLike, Z: Optional[ArrayLike]) -> Ar
155155 Y = np .asarray (Y )
156156
157157 if not all (type (xi ) == type (X [0 ]) for xi in X ): # noqa
158- raise ValueError ("All elements of X must be of the same type." )
158+ raise TypeError ("All elements of X must be of the same type." )
159159 if not all (type (yi ) == type (Y [0 ]) for yi in Y ): # noqa
160- raise ValueError ("All elements of Y must be of the same type." )
160+ raise TypeError ("All elements of Y must be of the same type." )
161161
162162 # Check if all elements are integers
163163 if np .issubdtype (type (X [0 ]), np .str_ ):
@@ -185,7 +185,7 @@ def _preprocess_inputs(X: ArrayLike, Y: ArrayLike, Z: Optional[ArrayLike]) -> Ar
185185 Z = Z .reshape (- 1 , 1 )
186186 for icol in range (Z .shape [1 ]):
187187 if not all (type (zi ) == type (Z [0 , icol ]) for zi in Z [:, icol ]): # noqa
188- raise ValueError (f"All elements of Z in column { icol } must be of the same type." )
188+ raise TypeError (f"All elements of Z in column { icol } must be of the same type." )
189189
190190 # XXX: needed when converting to only numpy API
191191 # Check if all elements are integers
@@ -271,7 +271,9 @@ def _power_divergence(
271271 if Z is None :
272272 # Compute the contingency table
273273 observed_xy , _ , _ = np .histogram2d (X , Y , bins = (np .unique (X ).size , np .unique (Y ).size ))
274- chi , p_value , dof , expected = stats .chi2_contingency (observed_xy , correction = correction , lambda_ = method )
274+ chi , p_value , dof , expected = stats .chi2_contingency (
275+ observed_xy , correction = correction , lambda_ = method
276+ )
275277
276278 # Step 2: If there are conditionals variables, iterate over unique states and do
277279 # the contingency test.
@@ -316,7 +318,9 @@ def _power_divergence(
316318 sub_table_z = (
317319 df .groupby (X_columns + Y_columns ).size ().unstack (Y_columns , fill_value = 1e-7 )
318320 )
319- c , _ , d , _ = stats .chi2_contingency (sub_table_z , correction = correction , lambda_ = method )
321+ c , _ , d , _ = stats .chi2_contingency (
322+ sub_table_z , correction = correction , lambda_ = method
323+ )
320324 chi += c
321325 dof += d
322326 except ValueError :
0 commit comments