neurodata / mgcpy-old

MGCPY WILL NO LONGER BE UPDATED. THE NEW REPO CAN BE FOUND HERE:
https://github.com/neurodata/hyppo
Apache License 2.0
31 stars 45 forks source link

Allow y in k sample transform to be 1 dimensional #154

Open bdpedigo opened 5 years ago

bdpedigo commented 5 years ago

This line breaks when y is 1d, does not even throw the error but breaks because y.shape[1] does not exist (index error)


#%% do MGC stuff...
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
 in 
      8     node_latent = np.concatenate((node_latent_pop1, node_latent_pop2), axis=0)
      9     pop_indicator = np.array(n_graphs * [0] + n_graphs * [1])
---> 10     u, v = k_sample_transform(node_latent, pop_indicator, is_y_categorical=True)
     11     mgc = MGC()
     12     p_val, meta = mgc.p_value(u, v, 100)

/miniconda3/envs/dos_and_donts/lib/python3.7/site-packages/mgcpy/hypothesis_tests/transforms.py in k_sample_transform(x, y, is_y_categorical)
     34         assert x.shape == y.shape, "Matrices X and Y need to be of same dimensions [n, p]"
     35     else:
---> 36         assert x.shape[0] == y.shape[0] and y.shape[1] == 1, "Matrices X and Y need to be of dimensions [n, p], [n, 1]"
     37 
     38     if not is_y_categorical:

IndexError: tuple index out of range

I'd consider using this or something more standardized to do input checking, (n,) dimensional should be fine IMO https://scikit-learn.org/stable/modules/generated/sklearn.utils.check_X_y.html