File tree Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 2
2
# coding: utf-8
3
3
"""Some higher-order functions that make useful tools."""
4
4
5
+ from labelled_functions .abstract import Unknown
5
6
from labelled_functions .labels import label , LabelledFunction
6
7
7
8
@@ -19,12 +20,13 @@ def func_returning_inputs(*args, **kwargs):
19
20
func_returning_inputs ,
20
21
name = f"{ func .name } " ,
21
22
input_names = func .input_names ,
22
- output_names = func .input_names + func .output_names ,
23
+ output_names = func .input_names + func .output_names if func . output_names is not Unknown else Unknown ,
23
24
default_values = func .default_values ,
24
25
)
25
26
26
27
return func_returning_inputs
27
28
29
+
28
30
def time (func ):
29
31
func = label (func )
30
32
Original file line number Diff line number Diff line change 9
9
10
10
import parso
11
11
12
- from .abstract import Unknown , AbstractLabelledCallable
12
+ from labelled_functions .abstract import Unknown , AbstractLabelledCallable
13
13
14
14
15
15
# API
@@ -106,7 +106,7 @@ def __init__(self,
106
106
if p [name ].default is not Parameter .empty }
107
107
108
108
# OUTPUT
109
- if output_names is Unknown :
109
+ if output_names is Unknown and function . __name__ != "<lambda>" :
110
110
try :
111
111
source = getsource (function )
112
112
output_names = _get_output_names_from_source (source )
Original file line number Diff line number Diff line change 4
4
import pytest
5
5
from copy import copy
6
6
7
+ from labelled_functions .abstract import Unknown
7
8
from labelled_functions .labels import LabelledFunction , label
8
9
from labelled_functions .decorators import keeping_inputs
9
10
@@ -54,6 +55,11 @@ def f(self, x):
54
55
assert lab_f (A (), x = 2 ) == 14
55
56
56
57
58
+ def test_lambda ():
59
+ ld = label (lambda foo : 2 * foo )
60
+ assert ld .input_names == ["foo" ]
61
+ assert ld .output_names is Unknown
62
+
57
63
def test_output_checking ():
58
64
la = LabelledFunction (add , output_names = ['shrubbery' ])
59
65
assert la ._has_never_been_run
You can’t perform that action at this time.
0 commit comments