Git Product home page Git Product logo

Comments (7)

clbarnes avatar clbarnes commented on July 22, 2024

Could you give us an adjacency matrix as a failing case we can build a test from? Your current example is OK if you don't mind sharing it, otherwise a minimal failing example would be great. Something like a CSV in a gist would be perfect.

from bctpy.

rschmaelzle avatar rschmaelzle commented on July 22, 2024

thanks for the help! I put it here: https://github.com/rschmaelzle/misc.git
The matrix can contain negative values (I comment out the respecive line in bctpy that complain), it also happens after I set B[B<0]=0.
Best, R

from bctpy.

clbarnes avatar clbarnes commented on July 22, 2024

The implementation here isn't defined for negative weights (and I don't profess to know enough about the algorithm to address that), so I also ditched the negative values. However, I didn't run into any issues running it on either python 2.7 or 3.5 with the below snippet.

def test_community_louvain_failing()
    x = np.load('path/to/does_not_work.npy')
    x[x < 0] = 0
    ci, q = bct.community_louvain(x)
    print(ci, q)
(array([1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8]), 0.72635748243481213)

I'm using numpy 1.11 and scipy 1.17 - possibly it's a versioning issue? If you're using a conda environment try doing a conda env export > environment.yml and posting that, or a conda list -e > spec-file.txt, or if you're using pip then pip freeze > requirements2.txt.

See my branch here https://github.com/clbarnes/bctpy/tree/bug-louvain-%2341 (there are a couple of other changes as my master branch is waiting to be merged into master but they don't touch the modularity code; I have checked on a branch rebased on base/master too)

See my CI build here https://travis-ci.org/clbarnes/bctpy/builds/127873637 (that uses numpy 1.10)

from bctpy.

rschmaelzle avatar rschmaelzle commented on July 22, 2024

Thanks, Chris! This helped! The error is on my side: I gave it a matrix and not an array. Saving it out converts to array, thus after re-importing everything works! Sorry!
re: negative values: You are right about general issues with negative values, but people I work with say that in this case (where B is prepared) it was ok.
Thanks for putting bct-py together! R

from bctpy.

clbarnes avatar clbarnes commented on July 22, 2024

Good to hear! It might be worth noting this in the documentation.

@aestrivex is the main man to thank!

from bctpy.

rschmaelzle avatar rschmaelzle commented on July 22, 2024

how? should i do anything?
@aestrivex thanks!

from bctpy.

clbarnes avatar clbarnes commented on July 22, 2024

No worries, I've added it to the readme changes already in a PR.

from bctpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.