We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent af0adfa commit f75856bCopy full SHA for f75856b
2 files changed
valid8/tests/issues/__init__.py
valid8/tests/issues/test_issue_53.py
@@ -0,0 +1,32 @@
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
30
31
32
0 commit comments