aestrivex/bctpy

get_components: length of a generator

Closed this issue · 3 comments

The line

cptsizes=np.zeros(len(cpts))

in get_components() raises the following error

*** TypeError: object of type 'generator' has no len()

One way to get rid of it is using

cptsizes=np.zeros(len(list(cpts)))

instead.

I am not initially able to reproduce this error using randomly generated
matrices with a range of components.

Can you provide what matrix you are using to generate this error? Also what
version of networkx are you using?

On Wed, Apr 8, 2015 at 5:18 PM, birkantunc notifications@github.com wrote:

The line

cptsizes=np.zeros(len(cpts))

in get_components() raises the following error

*** TypeError: object of type 'generator' has no len()

One way to get rid of it is using

cptsizes=np.zeros(len(list(cpts)))

instead.


Reply to this email directly or view it on GitHub
#8.

I could not figure out how to upload the matrix using github interface. I'm using the latest version of networkx (1.9.1)

I was using networkx 1.8.1, because that's the version that came with my python distribution and I've never really had a reason to update it.

In the meantime I guess the API has changed to return a generator instead of a list, and I can reproduce your error on the newer version.

Thanks for the report, it is fixed now