Skip to content
This repository was archived by the owner on Oct 29, 2020. It is now read-only.
This repository was archived by the owner on Oct 29, 2020. It is now read-only.

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

@bdpedigo

Description

@bdpedigo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions