GithubHelp home page GithubHelp logo

ingoscholtes / pathpy Goto Github PK

View Code? Open in Web Editor NEW
141.0 15.0 28.0 848 KB

pathpy is an OpenSource python package for the modeling and analysis of pathways and temporal networks using higher-order and multi-order graphical models

License: GNU Affero General Public License v3.0

Python 100.00%
temporal-networks pathways analysis sequential-data data data-mining python network-analysis networks graph

pathpy's People

Contributors

benassa-de-glassa avatar ingoscholtes avatar verginer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pathpy's Issues

Temporal network visualization with a little space between the nodes

Hello,

I am new to Pathpy and I was wondering if there is a way to increase the length of the edges. The nodes in my generated visualization are a little clumped together and I don't seem to find the name of the styling property that controls the length of the edges.

I'll be grateful if someone could provide an answer.

paths of length zero not added to network

Adding paths of length zero to a path object, e.g:

p = pp.Paths()
for i in range(10):
    p.add_path(tuple([i]))

When then generate a network path:

n = pp.Network.from_paths(p)

we get an empty network instead of one of isolated nodes:

n.nodes
defaultdict(dict, {})

Computing temporal betweenness and Closeness

Hello,

I am trying to do a comparison study about existing temporal betweenness and closeness methods.
However, whenever I run the method GetTemporalBetweenness I am getting this error,
minD, minPaths = Distances.GetMinTemporalDistance(t, delta=1, collect_paths=True)
NameError: name 'Distances' is not defined.
I am unable to find the module Distances in any of your github depots. I am wondering if this part of the code is somewhere ?

The same error happens also for closeness.

Regards,
Marwan

Some ideas on refactoring for ease of maintenance, extendability and compatibility with networkx.

The networkx project is, I think, a project which pathpy might look to be highly compatible with, since its users are among the most likely to use pathpy. To that end it would be useful to refactor the api to be in line with the PEP8 style guide as well as separating the algorithms working on the various objects from those objects (i.e. get_betweeness_preference for Paths becomes a function and not a method).

Here are a few daring proposals (just my opinion ๐Ÿ˜) that in part would break backward compatibility ๐Ÿ’ฅ

  • refactor variable names, methods and properties to PEP8 (e.g. getSequence() becomes sequence())
  • move data structures (i.e. Paths, HigherOrderNetwork, MarkovSequence and TemporalNetwork) into a classes sub-module (i.e. a folder) (inspired by structure of networkx)
  • move algorithms into an algorithms sumodules
    • this would allow more flexibility and transparency when adding or modifying algorithms later
    • by correctly loading them in the relevant __init__.py the additional level in the file hierachy would not be visible to the user.
    • This would mean that a user would call pathpy.betweenness_preference(paths_inst) instead of paths_inst.betweenness_preference() the latter behavior can still be maintained if desired
  • Implement a helper functions to convert patphy objects to most adequate nx equivalent an vice versa
    • reduces the barrier to entry to users of nx
    • benefits from algorithm already implemented in nx
  • Use the logging module in the python standard library instead of the current custom implementation (Log)
  • Write documentation in sphinx style (so it can be compiled and viewed in https://readthedocs.org/

I have already implemented some of these changes and kept the functionality equal to the current pathpy implementation (thanks to unit tests) (see here).

Sorry for long post.

isolated nodes not counted as components

Running the code:

tr_net = pp.Network()
for i in range(n):
    tr_net.add_node(i)

For n <= 2 we get:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-84-329b4db68bec> in <module>
----> 1 pp.algorithms.components.connected_components(tr_net)

/opt/tljh/user/lib/python3.6/site-packages/pathpy/algorithms/components.py in connected_components(network, lanczos_vecs, maxiter)
     48     if maxiter is None:
     49         maxiter = n*10
---> 50     vals, vecs = _sla.eigs(L, k=n, which="SM", return_eigenvectors=True)
     51 
     52     components = defaultdict(set)

/opt/tljh/user/lib/python3.6/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py in eigs(A, k, M, sigma, which, v0, ncv, maxiter, tol, return_eigenvectors, Minv, OPinv, OPpart)
   1247 
   1248     if k <= 0:
-> 1249         raise ValueError("k=%d must be greater than 0." % k)
   1250 
   1251     if k >= n - 1:

ValueError: k=0 must be greater than 0.

While for n>2 we get the following:
defaultdict(set, {})

Our expectation would have been to get the isolated nodes as components.

Exception when calculating sub paths of empty Paths object

Call of expandSubPaths on empty paths object raises exception

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/cluster/home/ingosc/Acyclic_Paths/src/pathpy/pathpy/Paths.py", line 298, in expandSubPaths
    for l in range(max(self.paths)):
ValueError: max() arg is an empty sequence

Test suit and Trevis CI integration

Hi @IngoScholtes

I have looked through the code since I find this project really nice and (also the paper),
and in the process of understanding it I have created a test suit covering 75% of pathpys codebase, which highlights a few bugs I have found, and several Errors which I could not fix
(e.g. in the code the package or object Distances and Utilities are referenced but never declared see for example GetTemporalBetweenness, GetTemporalBetweennessInstantaneous)

For my fork I have also set up a travis ci integration to test the code against several python versions.
Which does also highlight several version related "bugs" or unexpected behavior.

I didn't want to create a pull request with such a large change not knowing if it is appreciated.
So my question is whether you would like to incorporate the test suit, and if so how you would
like me submit the changes.

Luca

Misleading "to_undirected" method in Network class

The "to_undirected" method of the networks class loses the edge weights.
It would be better to provide a method that allows preserving weights and removes only the directedness. The user should be able to choose how this is performed (sum, average...)

Bug in HigherOrderNetwork.reduceToGCC

I used getgcc to extract the strongly connected component of a second-order network.

It returned an error, and said that dictionary changed size during interaction
del self.edges[(u,v)]

python2 compatibility

Nowhere in the documentation does it mention that this module is not python2 compatible, however:

import igraph
import numpy as np
import pathpy as pp

Results in the error:

File "/home/user99/miniconda2/lib/python2.7/site-packages/pathpy/HigherOrderNetwork.py", line 728
nonlocal index
^
SyntaxError: invalid syntax

It would be great if it was python2 compatible, but otherwise could you specify in the docs that it is not?

Bug in PageRank calculation

Call to HigherOrderNetwork.PageRank exits with ...

TypeError: can't multiply sequence by non-int of type 'float'

Bad Tutorial URL

In the tutorial, one of the URLs is pointing to the wrong location:

I Scholtes, N Wider, R Pfitzner, A Garas, CJ Tessone, F Schweitzer: Causality-driven slow-down and speed-up of diffusion in non-Markovian temporal networks, Nature Communications, 5, September 2014

Is this repo open source? No OSS License is specified.

Sorry to bring this up,

but I have noticed that this repo does not have a LICENSE file specifying how it may be used.
I don't intend on infringing on any intellectual property, but I would like to fiddle around with the code and maybe share it as well here on github, however as per the GitHub Terms of Service,
if no Open Source Licensing is explicitly stated,

the default copyright laws apply, meaning that you retain all rights to your source code and no one may reproduce, distribute, or create derivative works from your work.
https://help.github.com/articles/licensing-a-repository/

Maybe you would consider adding such as license?

see also: https://choosealicense.com/no-license/

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.