Skip to content

Commit ae6c960

Browse files
Merge pull request #53 from yuta-nakahara/develop-metatree-continuous
Develop metatree continuous
2 parents 6f102fd + 0b6d5eb commit ae6c960

File tree

21 files changed

+4066
-3212
lines changed

21 files changed

+4066
-3212
lines changed

bayesml/_check.py

Lines changed: 16 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:
@@ -59,6 +69,12 @@ def nonneg_int_vec(val,val_name,exception_class):
5969
return val
6070
raise(exception_class(val_name + " must be a 1-dimensional numpy.ndarray whose dtype is int. Its values must be non-negative (including 0)."))
6171

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+
6278
def nonneg_int_vecs(val,val_name,exception_class):
6379
if type(val) is np.ndarray:
6480
if np.issubdtype(val.dtype,np.integer) and val.ndim >= 1 and np.all(val>=0):

0 commit comments

Comments
 (0)