• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.assert_raises函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mlxtend.utils.assert_raises函数的典型用法代码示例。如果您正苦于以下问题:Python assert_raises函数的具体用法?Python assert_raises怎么用?Python assert_raises使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了assert_raises函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:RaoUmer,项目名称:mlxtend,代码行数:7,代码来源:test_base_regressor.py


示例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)
开发者ID:RaoUmer,项目名称:mlxtend,代码行数:7,代码来源:test_base_supervised_estimator.py


示例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)
开发者ID:CandyPythonFlow,项目名称:mlxtend,代码行数:7,代码来源:test_cluster.py


示例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)
开发者ID:CandyPythonFlow,项目名称:mlxtend,代码行数:7,代码来源:test_cluster.py


示例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)
开发者ID:chrinide,项目名称:mlxtend,代码行数:7,代码来源:test_checking_inputs.py


示例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)
开发者ID:chrinide,项目名称:mlxtend,代码行数:7,代码来源:test_base_estimator.py


示例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)
开发者ID:chrinide,项目名称:mlxtend,代码行数:7,代码来源:test_base_model.py


示例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)
开发者ID:laisun,项目名称:mlxtend,代码行数:7,代码来源:test_base.py


示例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:])
开发者ID:chrinide,项目名称:mlxtend,代码行数:7,代码来源:test_checking_inputs.py


示例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)
开发者ID:JJLWHarrison,项目名称:mlxtend,代码行数:7,代码来源:test_decision_regions.py


示例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)
开发者ID:chrinide,项目名称:mlxtend,代码行数:7,代码来源:test_regressor.py


示例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)
开发者ID:CandyPythonFlow,项目名称:mlxtend,代码行数:7,代码来源:test_cluster.py


示例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)
开发者ID:chrinide,项目名称:mlxtend,代码行数:7,代码来源:test_regressor.py


示例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)
开发者ID:JJLWHarrison,项目名称:mlxtend,代码行数:7,代码来源:test_decision_regions.py


示例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)
开发者ID:laisun,项目名称:mlxtend,代码行数:8,代码来源:test_base.py


示例16: test_format_kwarg_dictionaries_user_kwargs_invalid_type

def test_format_kwarg_dictionaries_user_kwargs_invalid_type():
    invalid_kwargs = 'not a dictionary'
    message = ('d must be of type dict or None, but got '
               '{} instead'.format(type(invalid_kwargs)))
    assert_raises(TypeError,
                  message,
                  format_kwarg_dictionaries,
                  user_kwargs=invalid_kwargs)
开发者ID:JJLWHarrison,项目名称:mlxtend,代码行数:8,代码来源:test_checking_inputs.py


示例17: test_input_array_1d

def test_input_array_1d():
    t = np.array([[1, 2], [3, 4]])
    assert_raises(ValueError,
                  'One or more input arrays are not 1-dimensional.',
                  mcnemar_table,
                  t,
                  t,
                  t)
开发者ID:vdthatte,项目名称:mlxtend,代码行数:8,代码来源:test_mcnemar_table.py


示例18: test_check_array_2

def test_check_array_2():
    X = list([[1], [2], [3]])
    est = _BaseEstimator(print_progress=0, random_seed=1)

    assert_raises(ValueError,
                  'X must be a numpy array',
                  est._check_arrays,
                  X)
开发者ID:chrinide,项目名称:mlxtend,代码行数:8,代码来源:test_base_estimator.py


示例19: test_predict_1

def test_predict_1():
    X = np.array([[1], [2], [3]])
    cl = _BaseCluster(print_progress=0, random_seed=1)

    assert_raises(AttributeError,
                  'Model is not fitted, yet.',
                  cl.predict,
                  X)
开发者ID:laisun,项目名称:mlxtend,代码行数:8,代码来源:test_base.py


示例20: test_check_labels_not_ok_1

def test_check_labels_not_ok_1():
    y = np.array([1, 3, 2])
    cl = BlankClassifier(print_progress=0, random_seed=1)
    assert_raises(AttributeError,
                  'Labels not in {(1, 2), (0, 1)}.\nFound (1, 2, 3)',
                  cl._check_target_array,
                  y,
                  {(0, 1), (1, 2)})
开发者ID:CandyPythonFlow,项目名称:mlxtend,代码行数:8,代码来源:test_cluster.py



注:本文中的mlxtend.utils.assert_raises函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mm_util.parse_rest_response函数代码示例发布时间:2022-05-27
下一篇:
Python tf_classifier.TfMultiLayerPerceptron类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap