ndexbio / ndex2-client

NDEx2 Client
BSD 3-Clause "New" or "Revised" License
6 stars 6 forks source link

Boolean attributes are treated as integers when converting networkx to NiceCXNetwork #83

Closed coleslaw481 closed 2 years ago

coleslaw481 commented 3 years ago

When using the method: ndex2.create_nice_cx_from_networkx() Boolean attributes are sometimes treated as integers. This was tested with networkx version 2.5.1

import ndex2
import networkx as nx

#Create a networkx graph with a boolean attribute
G = nx.Graph()
G.add_node(1, isRoot=False)
nx.get_node_attributes(G, 'isRoot')

print(ndex2.create_nice_cx_from_networkx(G).to_cx())

When run got this output:

[{'numberVerification': [{'longNumber': 281474976710655}]},
 {'metaData': [{'name': 'nodes',
    'elementCount': 1,
    'idCounter': 1,
    'version': '1.0',
    'consistencyGroup': 1,
    'properties': []},
   {'name': 'nodeAttributes',
    'elementCount': 1,
    'idCounter': 1,
    'version': '1.0',
    'consistencyGroup': 1,
    'properties': []}]},
 {'nodes': [{'@id': 1, 'n': 1}]},
 {'nodeAttributes': [{'po': 1, 'n': 'isRoot', 'v': False, 'd': 'integer'}]},
 {'status': [{'error': '', 'success': True}]}]

The data type d for the nodeAttribute should be a boolean and NOT an integer

Extracted from: https://ndexbio.atlassian.net/browse/UD-1753

coleslaw481 commented 2 years ago

Fixed with commit: To github.com:ndexbio/ndex2-client.git 5c899e5..1a6873e v3.5.0 -> v3.5.0