File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ import numpy as np
2+
3+ from mini_lambda import x
4+ from valid8 import validate , validate_arg , and_
5+
6+
7+ def test_numpy_bool_is_ok ():
8+ """ Tests that numpy booleans can be used as success result by validation functions"""
9+
10+ # a numpy float is not a python float
11+ np_float = np .float_ (1.0 )
12+
13+ # numpy bools are not python bools
14+ assert np_float > 0 is not True
15+ assert 'numpy' in "%s" % (np_float > 0 ).__class__
16+
17+ # simple checker
18+ validate ('np_float' , np_float , min_value = 1 )
19+
20+ # more complex checker
21+ @validate_arg ('a' , lambda x : x >= 1 )
22+ def foo (a ):
23+ return
24+
25+ foo (np_float )
26+
27+ # even more complex checker
28+ @validate_arg ('a' , and_ (x > 0 , lambda x : x >= 1 ))
29+ def foo (a ):
30+ return
31+
32+ foo (np_float )
You can’t perform that action at this time.
0 commit comments