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

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

Closed
VinsRR opened this issue May 10, 2024 · 2 comments · Fixed by #201
Closed

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

VinsRR opened this issue May 10, 2024 · 2 comments · Fixed by #201
Assignees
Labels
bug Something isn't working

Comments

@VinsRR
Copy link
Contributor

VinsRR commented May 10, 2024

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'
@VinsRR VinsRR added the bug Something isn't working label May 10, 2024
@IngoScholtes IngoScholtes self-assigned this May 15, 2024
@IngoScholtes
Copy link
Member

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
Copy link
Contributor

hackl commented Sep 9, 2024

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.

@IngoScholtes IngoScholtes linked a pull request Sep 19, 2024 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants