Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: awilliamsAt the moment i've got two solutions for this.
You can either use a filter node, emit the fields with .ifNull(0) on the affected fields. This works great if you're working with a small subset of static fields, but if the input is dynamic then it presents a problem.
The second solution was a small Python node to look for numeric fields and set the value to zero in the instance where its null.
node:Zero_Fields
bretype:core::Python
editor:Label=Zero Fields
editor:sortkey=51cd2fdc1d4f628f
input:51cd2fa77a717730/PivotedData=Calculate_Flow.51cd2dd1177116a2
output:51cd303605e734c9/out1=
prop:Python2Implementation=<<EOX
import braininfo
def setup(brainNodeControlObj, BrainNodeClass):
class BrainNode(BrainNodeClass):
def initialize(self):
super(BrainNode, self).initialize()
self.keys = []
md = self.inputs[0].metadata
for k, t in md:
if t in ['int', 'long', 'bint', 'blong', 'double', 'bdouble']:
self.keys.append(k)
def finalize(self, val):
super(BrainNode, self).finalize(val)
def pump(self, quant):
while quant.permitsRunning(self):
rec = self.inputs[0].read()
if not rec: return False
for k in self.keys:
if rec[k] == None:
rec[k] = 0
self.outputs[0].write(rec)
return True
return BrainNode
EOX
editor:XY=600,410
end:Zero_Fields