Skip to main content
Question

Quick Test of Hub Transformer

  • December 1, 2017
  • 3 replies
  • 14 views

mark2atsafe
Safer
Forum|alt.badge.img+56

Hey folks,

If anyone has a couple of minutes to spare, could you do me a favour and test this transformer on the FME hub: https://hub.safe.com/transformers/spatialsorter

It should run to completion (and not fail in a Python error) and it should return output like this: https://www.screencast.com/t/kRP9ysTq3N (I ran it on the Parks training dataset, but it should work on any dataset).

Thanks. I've had problems where it works on one machine but not another. I thought I had it cracked, but the test workspace fails on the hub. I'd like to check if it's just the hub (or just linux) or if everyone has issues.

Mark

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

takashi
Celebrity
  • 7843 replies
  • December 2, 2017

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.


takashi
Celebrity
  • 7843 replies
  • December 3, 2017

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

 

 


mark2atsafe
Safer
Forum|alt.badge.img+56
  • Author
  • Safer
  • 2554 replies
  • December 4, 2017

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!