Hi @Mark2AtSafe, with Python 3.x interpreter, it seems that the numeric values contained by a numpy.ndarray have to be cast to "int" or "float" values explicitly when you pass them to the FMEFeature.setAttribute method. Try this.
def processFeature(feature):
curvenum = feature.getAttribute('SortPrecision')
for i, s in enumerate(hilbert_curve(curvenum)):
for j, v in enumerate(s):
feature.setAttribute('_list2{%d}.sub{%d}' % (i, j), int(v))
In addition, the "numpy.ndenumerate" function could be used effectively here.
def processFeature(feature):
curvenum = feature.getAttribute('SortPrecision')
for (i, j), v in ndenumerate(hilbert_curve(curvenum)):
feature.setAttribute('_list2{%d}.sub{%d}' % (i, j), int(v))
Hope this helps.
Hi @Mark2AtSafe, with Python 3.x interpreter, it seems that the numeric values contained by a numpy.ndarray have to be cast to "int" or "float" values explicitly when you pass them to the FMEFeature.setAttribute method. Try this.
def processFeature(feature):
curvenum = feature.getAttribute('SortPrecision')
for i, s in enumerate(hilbert_curve(curvenum)):
for j, v in enumerate(s):
feature.setAttribute('_list2{%d}.sub{%d}' % (i, j), int(v))
In addition, the "numpy.ndenumerate" function could be used effectively here.
def processFeature(feature):
curvenum = feature.getAttribute('SortPrecision')
for (i, j), v in ndenumerate(hilbert_curve(curvenum)):
feature.setAttribute('_list2{%d}.sub{%d}' % (i, j), int(v))
Hope this helps.
For what it's worth, this implementation could increase the performance a bit.
spatialsorter-update-test-2.fmw
Hi @Mark2AtSafe, with Python 3.x interpreter, it seems that the numeric values contained by a numpy.ndarray have to be cast to "int" or "float" values explicitly when you pass them to the FMEFeature.setAttribute method. Try this.
def processFeature(feature):
curvenum = feature.getAttribute('SortPrecision')
for i, s in enumerate(hilbert_curve(curvenum)):
for j, v in enumerate(s):
feature.setAttribute('_list2{%d}.sub{%d}' % (i, j), int(v))
In addition, the "numpy.ndenumerate" function could be used effectively here.
def processFeature(feature):
curvenum = feature.getAttribute('SortPrecision')
for (i, j), v in ndenumerate(hilbert_curve(curvenum)):
feature.setAttribute('_list2{%d}.sub{%d}' % (i, j), int(v))
Hope this helps.
Thank you Takashi! I implemented the int(v) part and it works fine now. I'm not going to try the other parts because now it is working I don't want to touch anything else!