Skip to content

Commit 0e0192a

Browse files
committed
Add pos_int_vec
1 parent 4a863ac commit 0e0192a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

bayesml/_check.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ def nonneg_int_vec(val,val_name,exception_class):
5959
return val
6060
raise(exception_class(val_name + " must be a 1-dimensional numpy.ndarray whose dtype is int. Its values must be non-negative (including 0)."))
6161

62+
def pos_int_vec(val,val_name,exception_class):
63+
if type(val) is np.ndarray:
64+
if np.issubdtype(val.dtype,np.integer) and val.ndim == 1 and np.all(val>0):
65+
return val
66+
raise(exception_class(val_name + " must be a 1-dimensional numpy.ndarray whose dtype is int. Its values must be positive (not including 0)."))
67+
6268
def nonneg_int_vecs(val,val_name,exception_class):
6369
if type(val) is np.ndarray:
6470
if np.issubdtype(val.dtype,np.integer) and val.ndim >= 1 and np.all(val>=0):

0 commit comments

Comments
 (0)