Commit 8f372b5e authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[test][prefix] Make loop and loop user algorithm use different dataformat

This will ensure that exporting algorithm works correctly.
parent 3ac4751a
......@@ -12,10 +12,10 @@
},
"loop": {
"request": {
"type": "user/single_integer/1"
"type": "user/1d_array_of_integers/1"
},
"answer": {
"type": "user/single_integer/1"
"type": "user/single_integer64/1"
}
}
}
......
......@@ -33,16 +33,17 @@
# #
###################################################################################
import numpy as np
class Algorithm:
class Algorithm:
def __init__(self):
self.threshold = None
def setup(self, parameters):
self.threshold = parameters['threshold']
self.threshold = parameters["threshold"]
return True
def validate(self, result):
value = result.value
return (value < self.threshold, {'value': value})
value = result.value[0]
return (value < self.threshold, {"value": np.int64(value)})
......@@ -18,10 +18,10 @@
},
"loop": {
"request": {
"type": "user/single_integer/1"
"type": "user/1d_array_of_integers/1"
},
"answer": {
"type": "user/single_integer/1"
"type": "user/single_integer64/1"
}
}
}
......
......@@ -36,26 +36,22 @@
import numpy as np
class Algorithm:
class Algorithm:
def process(self, data_loaders, outputs, loop_channel):
cnt = 10
is_valid, _ = loop_channel.validate({'value': np.int32(cnt)})
is_valid, _ = loop_channel.validate({"value": np.full(10, cnt)})
while not is_valid:
cnt = cnt - 1
is_valid, _ = loop_channel.validate({'value': np.int32(cnt)})
is_valid, _ = loop_channel.validate({"value": np.full(10, cnt)})
data_loader = data_loaders.loaderOf('in')
data_loader = data_loaders.loaderOf("in")
for i in range(data_loader.count()):
view = data_loader.view('in', i)
view = data_loader.view("in", i)
(data, start, end) = view[view.count() - 1]
value = data['in'].value
value = data["in"].value
new_value = value + cnt
outputs['out'].write({
'value': np.int32(new_value),
},
end
)
outputs["out"].write({"value": np.int32(new_value)}, end)
return True
......@@ -18,10 +18,10 @@
},
"loop": {
"request": {
"type": "user/single_integer/1"
"type": "user/1d_array_of_integers/1"
},
"answer": {
"type": "user/single_integer/1"
"type": "user/single_integer64/1"
}
}
}
......
......@@ -40,10 +40,10 @@ import numpy as np
class Algorithm:
def process(self, inputs, data_loaders, outputs, loop_channel):
cnt = 10
is_valid, _ = loop_channel.validate({"value": np.int32(cnt)})
is_valid, _ = loop_channel.validate({"value": np.full(10, cnt)})
while not is_valid:
cnt = cnt - 1
is_valid, _ = loop_channel.validate({"value": np.int32(cnt)})
is_valid, _ = loop_channel.validate({"value": np.full(10, cnt)})
value = inputs["in"].data.value
new_value = value + cnt
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment