Skip to content

Commit e267f23

Browse files
committed
Add pos_ints
1 parent 0e0192a commit e267f23

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

bayesml/_check.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ def nonneg_ints(val,val_name,exception_class):
4747
return val
4848
raise(exception_class(val_name + " must be int or a numpy.ndarray whose dtype is int. Its values must be non-negative (including 0)."))
4949

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+
5060
def int_vec(val,val_name,exception_class):
5161
if type(val) is np.ndarray:
5262
if np.issubdtype(val.dtype,np.integer) and val.ndim == 1:

0 commit comments

Comments
 (0)