0

I'm inserting nodes with feature vectors into Neo4j using py2neo. It works on almost all of my data. In two cases, though, the vectors contained NaN values, which caused Neo4j to return a 500 error when I tried to create the node.

Example 'good' vector: 
[0.0113546584773214, 0.0013764569567850638, 0.0007963202777833693, 0.00024471203511268117, 0.000390211070019412, 0.0028226812771905787, 0.04202329389178023, 0.0016958982585343057, 0.00014684726916060307, 0.000531159187816418, 0.0013412474934636795, 2.1611844247944313e-05, 0.0, 0.0, 0.0, 0.0]

Example 'bad' vector:
[nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, 0.0, 0.0, 0.027777777777777776, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

Is there some kind of encoding I need to do so Neo4j will accept them?

betseyb
  • 1,302
  • 2
  • 18
  • 37

1 Answers1

1

NaN isn't a value that Neo4j supports*.

*Technically, it may be able to support NaN at a store level but the Neo remoting protocol uses JSON which cannot encode it.

I'm afraid you'll have to find an alternative way to store these kinds of values that doesn't depend on NaN.

Nigel Small
  • 4,475
  • 1
  • 17
  • 15