Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Something is wrong in the ClusterGenerator #1

Open
posmat opened this issue Jul 5, 2021 · 1 comment
Open

Something is wrong in the ClusterGenerator #1

posmat opened this issue Jul 5, 2021 · 1 comment

Comments

@posmat
Copy link

posmat commented Jul 5, 2021

There is a line:
if not all(hasattr(elem, 'iter') and len(elem) == self.n_feats for elem in self.distributions)
raise ValueError('Invalid distributions input! Input must have dimensions (n_clusters, n_feats).')

Because self.distributions is a list, then len(elem) is the character number of the distribution string. e.g. 'gaussian' is 8 character, so this line demands that the n_feats to be 8

@dcferreira
Copy link
Collaborator

Hi @orbennix, thanks for the message.

I haven't touched this code in a while, so forgive me if I say something wrong.
As far as I can tell, you're referring to line 149 here, right?

# check validity of self.distributions, and turning it into a (n_clusters, n_feats) matrix
if hasattr(self.distributions, '__iter__') and not type(self.distributions) == str:
if len(self.distributions) != self.n_clusters:
raise ValueError('There must be exactly one distribution input for each cluster!')
if hasattr(self.distributions[0], '__iter__'):
if not all(hasattr(elem, '__iter__') and len(elem) == self.n_feats for elem in self.distributions):
raise ValueError('Invalid distributions input! Input must have dimensions (n_clusters, n_feats).')
else:
self.distributions = [self.distributions] * self.n_clusters

As far as I can tell, this line checks if the input for the distributions is a matrix of dimension n_clusters x n_feats.
Indeed if you send it a list of strings (as opposed to a list of lists of strings), the check would verify the wrong thing.

Would you care to make a pull request for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants