@@ -47,6 +47,16 @@ def nonneg_ints(val,val_name,exception_class):
47
47
return val
48
48
raise (exception_class (val_name + " must be int or a numpy.ndarray whose dtype is int. Its values must be non-negative (including 0)." ))
49
49
50
+ def pos_ints (val ,val_name ,exception_class ):
51
+ try :
52
+ return pos_int (val ,val_name ,exception_class )
53
+ except :
54
+ pass
55
+ if type (val ) is np .ndarray :
56
+ if np .issubdtype (val .dtype ,np .integer ) and np .all (val > 0 ):
57
+ return val
58
+ raise (exception_class (val_name + " must be int or a numpy.ndarray whose dtype is int. Its values must be positive (not including 0)." ))
59
+
50
60
def int_vec (val ,val_name ,exception_class ):
51
61
if type (val ) is np .ndarray :
52
62
if np .issubdtype (val .dtype ,np .integer ) and val .ndim == 1 :
@@ -59,6 +69,12 @@ def nonneg_int_vec(val,val_name,exception_class):
59
69
return val
60
70
raise (exception_class (val_name + " must be a 1-dimensional numpy.ndarray whose dtype is int. Its values must be non-negative (including 0)." ))
61
71
72
+ def pos_int_vec (val ,val_name ,exception_class ):
73
+ if type (val ) is np .ndarray :
74
+ if np .issubdtype (val .dtype ,np .integer ) and val .ndim == 1 and np .all (val > 0 ):
75
+ return val
76
+ raise (exception_class (val_name + " must be a 1-dimensional numpy.ndarray whose dtype is int. Its values must be positive (not including 0)." ))
77
+
62
78
def nonneg_int_vecs (val ,val_name ,exception_class ):
63
79
if type (val ) is np .ndarray :
64
80
if np .issubdtype (val .dtype ,np .integer ) and val .ndim >= 1 and np .all (val >= 0 ):
0 commit comments