当前位置: 首页>>代码示例>>Python>>正文


Python utils.assert_raises函数代码示例

本文整理汇总了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)
开发者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


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