本文整理汇总了Python中mlxtend.utils.assert_raises函数的典型用法代码示例。如果您正苦于以下问题:Python assert_raises函数的具体用法?Python assert_raises怎么用?Python assert_raises使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_raises函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_float_fail
def test_float_fail():
y = np.array([1, 2], dtype=np.int64)
reg = _BaseRegressor(print_progress=0, random_seed=1)
assert_raises(AttributeError,
'y must be a float array.\nFound int64',
reg._check_target_array,
y)
示例2: test_fit_1
def test_fit_1():
X = np.array([[1], [2], [3]])
est = _BaseSupervisedEstimator(print_progress=0, random_seed=1)
assert_raises(TypeError,
"fit() missing 1 required positional argument: 'y'",
est.fit,
X)
示例3: test_check_labels_positive_notok
def test_check_labels_positive_notok():
y = np.array([1, 1, -1])
cl = BlankClassifier(print_progress=0, random_seed=1)
assert_raises(AttributeError,
'y array must not contain negative labels.\nFound [-1 1]',
cl._check_target_array,
y)
示例4: test_fit_1
def test_fit_1():
X = np.array([[1], [2], [3]])
est = BlankClassifier(print_progress=0, random_seed=1)
assert_raises(TypeError,
"fit() missing 1 required positional argument: 'y'",
est.fit,
X)
示例5: test_unequal_length_X
def test_unequal_length_X():
assert_raises(ValueError,
('y and X must contain the same number of samples. '
'Got y: 4, X: 3'),
check_Xy,
X[1:],
y)
示例6: test_check_array_1
def test_check_array_1():
X = np.array([1, 2, 3])
est = _BaseEstimator(print_progress=0, random_seed=1)
assert_raises(ValueError,
'X must be a 2D array. Try X[:, numpy.newaxis]',
est._check_arrays,
X)
示例7: test_check_array_1
def test_check_array_1():
X = np.array([1, 2, 3])
est = BlankModel()
assert_raises(ValueError,
'X must be a 2D array. Try X[:, numpy.newaxis]',
est._check_arrays,
X)
示例8: test_check_array_1
def test_check_array_1():
X = np.array([1, 2, 3])
cl = _BaseCluster(print_progress=0, random_seed=1)
assert_raises(ValueError,
'X must be a 2D array. Try X[:, numpy.newaxis]',
cl._check_array,
X)
示例9: test_unequal_length_y
def test_unequal_length_y():
assert_raises(ValueError,
('y and X must contain the same number of samples. '
'Got y: 3, X: 4'),
check_Xy,
X,
y[1:])
示例10: test_filler_feature_values_fail
def test_filler_feature_values_fail():
sr.fit(X, y)
assert_raises(ValueError,
'Filler values must be provided when '
'X has more than 2 training features.',
plot_decision_regions,
X, y, sr)
示例11: test_fit_1
def test_fit_1():
X = np.array([[1], [2], [3]])
est = BlankRegressor()
assert_raises(TypeError,
"fit() missing 1 required positional argument: 'y'",
est.fit,
X)
示例12: test_check_labels_interger_notok
def test_check_labels_interger_notok():
y = np.array([1., 2.], dtype=np.float64)
cl = BlankClassifier(print_progress=0, random_seed=1)
assert_raises(AttributeError,
'y must be an integer array.\nFound float64',
cl._check_target_array,
y)
示例13: test_float_fail
def test_float_fail():
y = np.array([1, 2], dtype=np.int64)
reg = BlankRegressor()
assert_raises(AttributeError,
'y must be a float array.\nFound int64',
reg._check_target_array,
y)
示例14: test_y_int_ary
def test_y_int_ary():
sr.fit(X[:, :2], y)
assert_raises(ValueError,
'y must be an integer array. Found float64. '
'Try passing the array as y.astype(np.integer)',
plot_decision_regions,
X[:, :2], y.astype(np.float), sr)
示例15: test_check_array_2
def test_check_array_2():
X = list([[1], [2], [3]])
cl = _BaseCluster(print_progress=0, random_seed=1)
assert_raises(ValueError,
'X must be a numpy array',
cl._check_array,
X)