cytoscape / py2cytoscape

Python utilities for Cytoscape and Cytoscape.js
https://py2cytoscape.readthedocs.io
MIT License
178 stars 45 forks source link

py2cytoscape: index is reset multiple times within a for loop in util.name2suid() #78

Closed empet closed 5 years ago

empet commented 5 years ago

The static method util.name2suid repeats n times index resetting, table.set_index(["SUID"], inplace=True), where n=len(list(table_index)) https://github.com/cytoscape/py2cytoscape/blob/develop/py2cytoscape/data/util_network.py:

subset= table['name']
name2suid = {}
for suid in subset.index:
     name2suid[subset[suid]] = suid
     table.set_index(["SUID"],inplace=True)

There is no reason in resetting the index even after the loop for, because the table is no longer used in the body of that method. Apparently, it doesn't hurt, but after the first index reset, there is no column SUID to set it as index and the method ends by displaying the error Key 'SUID'

Cytoscape 3.7.1, Java 1.8.0_162