1
1
import numpy as np
2
2
import typing as ty
3
- import os
3
+ import importlib
4
4
import pytest
5
5
6
6
from ..submitter import Submitter
7
7
from ..core import Workflow
8
8
from ...mark import task , annotate
9
9
10
+ if importlib .util .find_spec ("numpy" ) is None :
11
+ pytest .skip ("can't find numpy library" , allow_module_level = True )
12
+
10
13
11
14
@task
12
15
@annotate ({"return" : {"b" : ty .Any }})
@@ -16,12 +19,11 @@ def arrayout(val):
16
19
17
20
def test_multiout (plugin ):
18
21
""" testing a simple function that returns a numpy array"""
19
- cache_dir = os .path .join (os .getcwd (), "cache3" )
20
- wf = Workflow ("wf" , input_spec = ["val" ], val = [0 , 1 , 2 ], cache_dir = cache_dir )
21
- wf .add (arrayout (name = "mo" , val = wf .lzin .val , cache_dir = cache_dir ))
22
+ wf = Workflow ("wf" , input_spec = ["val" ], val = [0 , 1 , 2 ])
23
+ wf .add (arrayout (name = "mo" , val = wf .lzin .val ))
22
24
wf .mo .split ("val" ).combine ("val" )
23
25
24
- wf .set_output ([("b " , wf .mo .lzout .b )])
26
+ wf .set_output ([("array " , wf .mo .lzout .b )])
25
27
26
28
with Submitter (plugin = plugin , n_procs = 2 ) as sub :
27
29
sub (runnable = wf )
@@ -30,4 +32,4 @@ def test_multiout(plugin):
30
32
31
33
assert results [0 ] == {"wf.val" : [0 , 1 , 2 ]}
32
34
for el in range (3 ):
33
- assert np .array_equal (results [1 ].output .b [el ], np .array ([el , el ]))
35
+ assert np .array_equal (results [1 ].output .array [el ], np .array ([el , el ]))
0 commit comments