pathpy / pathpyG

GPU-accelerated Next-Generation Network Analytics and Graph Learning for Time Series Data on Complex Networks.
https://www.pathpy.net
GNU Affero General Public License v3.0
31 stars 1 forks source link

import and plotting fail for (some) netzschleuder dataset #177

Open VinsRR opened 4 months ago

VinsRR commented 4 months ago

Some of the netzschleuder datasets cannot be imported; others can be imported but cannot be plotted. I'm putting both cases together because the plot likely fails because of something not being set up during import.

For example, "polbooks" can be imported but cannot be plotted

empirical = pp.io.read_netzschleuder_network("polbooks”)
pp.plot(empirical)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[28], line 1
----> 1 pp.plot(empirical)

File /opt/conda/lib/python3.10/site-packages/pathpyG/visualisations/__init__.py:110, in plot(data, kind, **kwargs)
    106         raise NotImplementedError
    108 filename = kwargs.pop("filename", None)
--> 110 plt = PLOT_CLASSES[kind](data, **kwargs)
    111 if filename:
    112     plt.save(filename, **kwargs)

File /opt/conda/lib/python3.10/site-packages/pathpyG/visualisations/network_plots.py:125, in NetworkPlot.__init__(self, network, **kwargs)
    123 self.network = network
    124 self.config = kwargs
--> 125 self.generate()

File /opt/conda/lib/python3.10/site-packages/pathpyG/visualisations/network_plots.py:130, in NetworkPlot.generate(self)
    128 """Generate the plot."""
    129 self._compute_edge_data()
--> 130 self._compute_node_data()
    131 self._compute_layout()
    132 self._cleanup_config()

File /opt/conda/lib/python3.10/site-packages/pathpyG/visualisations/network_plots.py:146, in NetworkPlot._compute_node_data(self)
    143 categories = {a.replace("node_", "") for a in self.network.node_attrs()}.intersection(attributes)
    145 # add node data to data dict
--> 146 self._get_node_data(nodes, attributes, attr, categories)
    148 # convert needed attributes to useful values
    149 attr["color"] = self._convert_color(attr["color"], mode="node")

File /opt/conda/lib/python3.10/site-packages/pathpyG/visualisations/network_plots.py:176, in NetworkPlot._get_node_data(self, nodes, attributes, attr, categories)
    173 # add edge attributes if needed
    174 for attribute in attributes:
    175     attr[attribute][uid] = (
--> 176         self.network[f"node_{attribute}", uid].item() if attribute in categories else None
    177     )

AttributeError: 'list' object has no attribute ‘item'

.

Instead, for "student_cooperation", the import fails.
empirical = pp.io.read_netzschleuder_network("student_cooperation")


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[29], line 1
----> 1 empirical = pp.io.read_netzschleuder_network("student_cooperation") # other networks don t seem to work
      2 empirical.mapping = pp.IndexMap(range(empirical.N))

File /opt/conda/lib/python3.10/site-packages/pathpyG/io/netzschleuder.py:458, in read_netzschleuder_network(name, net, ignore_temporal, multiedges, base_url)
    455     decompressed = reader.readall()
    457     # parse graphtool binary format
--> 458     return parse_graphtool_format(bytes(decompressed))
    460 except ModuleNotFoundError:
    461     msg = 'Package zstandard is required to decompress graphtool files. Please install module, e.g., using "pip install zstandard.'

File /opt/conda/lib/python3.10/site-packages/pathpyG/io/netzschleuder.py:275, in parse_graphtool_format(data, id_node_attr)
    273 for a in edge_attr:
    274     if not a.startswith('edge_'):
--> 275         g.data['edge_{0}'.format(a)] = torch.tensor(edge_attr[a], dtype=torch.float).to(config['torch']['device'])
    276 for a in graph_attr:
    277     g.data[a] = graph_attr[a]

ValueError: too many dimensions 'str'
IngoScholtes commented 2 weeks ago

These are two separate issues:

The failure to plot the polbooks data set is related to the code to plot networks, which seemingly cannot handle some node attributes. I'm including @hackl in the assignee list.

The failure to load the student_cooperation data set is an issue of the code to read the netzschleuder format. I will check how to fix this.

hackl commented 2 weeks ago

I will look at how to include node attributes in the plot. I think currently, it is not supported because of the new data format used in pathpyG.