當前位置: 首頁>>代碼示例>>Python>>正文


Python signature.Signature類代碼示例

本文整理匯總了Python中sacred.config.signature.Signature的典型用法代碼示例。如果您正苦於以下問題:Python Signature類的具體用法?Python Signature怎麽用?Python Signature使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Signature類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_construct_arguments_completes_kwargs_from_options

def test_construct_arguments_completes_kwargs_from_options():
    s = Signature(bariza)
    args, kwargs = s.construct_arguments([2, 4], {}, {'c': 6})
    assert args == [2, 4]
    assert kwargs == {'c': 6}
    s = Signature(complex_function_name)
    args, kwargs = s.construct_arguments([], {'c': 6, 'b': 7}, {'a': 1})
    assert args == []
    assert kwargs == {'a': 1, 'c': 6, 'b': 7}
開發者ID:IDSIA,項目名稱:sacred,代碼行數:9,代碼來源:test_signature_py3.py

示例2: test_get_free_parameters

def test_get_free_parameters():
    free = Signature(foo).get_free_parameters([], {})
    assert free == []
    free = Signature(bariza).get_free_parameters([], {'c': 3})
    assert free == ['a', 'b']
    free = Signature(complex_function_name).get_free_parameters([], {})
    assert free == ['a', 'b', 'c']
    free = Signature(_name_with_underscore_).get_free_parameters([], {})
    assert free == ['fo', 'bar']
    s = Signature(__double_underscore__)
    assert s.get_free_parameters([1, 2, 3], {}) == []
開發者ID:IDSIA,項目名稱:sacred,代碼行數:11,代碼來源:test_signature.py

示例3: test_construct_arguments_without_duplicates_passes

def test_construct_arguments_without_duplicates_passes():
    s = Signature(bariza)
    s.construct_arguments([1, 2], {'c': 5}, {})

    s = Signature(complex_function_name)
    s.construct_arguments([1], {'b': 4}, {})

    s = Signature(FunCTIonWithCAPItals)
    s.construct_arguments([], {'a': 6, 'b': 6, 'c': 6}, {})
開發者ID:IDSIA,項目名稱:sacred,代碼行數:9,代碼來源:test_signature.py

示例4: test_construct_arguments_with_duplicate_args_raises_typeerror

def test_construct_arguments_with_duplicate_args_raises_typeerror():
    multiple_values = re.compile(".*multiple values.*")
    with pytest.raises(TypeError) as excinfo:
        s = Signature(bariza)
        s.construct_arguments([1, 2, 3], {'a': 4, 'b': 5}, {})
    assert multiple_values.match(excinfo.value.args[0])
    with pytest.raises(TypeError) as excinfo:
        s = Signature(complex_function_name)
        s.construct_arguments([1], {'a': 4}, {})
    assert multiple_values.match(excinfo.value.args[0])
    with pytest.raises(TypeError) as excinfo:
        s = Signature(FunCTIonWithCAPItals)
        s.construct_arguments([1, 2, 3], {'c': 6}, {})
    assert multiple_values.match(excinfo.value.args[0])
開發者ID:IDSIA,項目名稱:sacred,代碼行數:14,代碼來源:test_signature.py

示例5: test_construct_arguments_raises_if_args_unfilled

def test_construct_arguments_raises_if_args_unfilled():
    s = Signature(bariza)
    missing = re.compile(".*missing.*")
    with pytest.raises(MissingConfigError) as excinfo:
        s.construct_arguments([], {}, {})
    assert missing.match(excinfo.value.args[0])
    with pytest.raises(MissingConfigError) as excinfo:
        s.construct_arguments([1, 2], {}, {})
    assert missing.match(excinfo.value.args[0])
    with pytest.raises(MissingConfigError) as excinfo:
        s.construct_arguments([1], {'b': 3}, {})
    assert missing.match(excinfo.value.args[0])
    with pytest.raises(MissingConfigError) as excinfo:
        s.construct_arguments([1], {'c': 5}, {})
    assert missing.match(excinfo.value.args[0])
開發者ID:IDSIA,項目名稱:sacred,代碼行數:15,代碼來源:test_signature.py

示例6: test_construct_arguments_without_options_returns_same_args_kwargs

def test_construct_arguments_without_options_returns_same_args_kwargs():
    s = Signature(foo)
    args, kwargs = s.construct_arguments([], {}, {})
    assert args == []
    assert kwargs == {}

    s = Signature(bariza)
    args, kwargs = s.construct_arguments([2, 4, 6], {}, {})
    assert args == [2, 4, 6]
    assert kwargs == {}

    s = Signature(complex_function_name)
    args, kwargs = s.construct_arguments([2], {'c': 6, 'b': 7}, {})
    assert args == [2]
    assert kwargs == {'c': 6, 'b': 7}

    s = Signature(_name_with_underscore_)
    args, kwargs = s.construct_arguments([], {'fo': 7, 'bar': 6}, {})
    assert args == []
    assert kwargs == {'fo': 7, 'bar': 6}
開發者ID:IDSIA,項目名稱:sacred,代碼行數:20,代碼來源:test_signature.py

示例7: test_construct_arguments_for_bound_method

def test_construct_arguments_for_bound_method():
    s = Signature(SomeClass.bla)
    args, kwargs = s.construct_arguments([1], {'b': 2}, {'c': 3}, bound=True)
    assert args == [1]
    assert kwargs == {'b': 2, 'c': 3}
開發者ID:IDSIA,項目名稱:sacred,代碼行數:5,代碼來源:test_signature.py

示例8: test_construct_arguments_does_not_raise_for_missing_defaults

def test_construct_arguments_does_not_raise_for_missing_defaults():
    s = Signature(complex_function_name)
    s.construct_arguments([], {}, {})
開發者ID:IDSIA,項目名稱:sacred,代碼行數:3,代碼來源:test_signature.py

示例9: test_construct_arguments_does_not_raise_if_all_args_filled

def test_construct_arguments_does_not_raise_if_all_args_filled():
    s = Signature(bariza)
    s.construct_arguments([1, 2, 3], {}, {})
    s.construct_arguments([1, 2], {'c': 6}, {})
    s.construct_arguments([1], {'b': 6, 'c': 6}, {})
    s.construct_arguments([], {'a': 6, 'b': 6, 'c': 6}, {})
開發者ID:IDSIA,項目名稱:sacred,代碼行數:6,代碼來源:test_signature.py

示例10: test_construct_arguments_overwrites_defaults

def test_construct_arguments_overwrites_defaults():
    s = Signature(complex_function_name)
    args, kwargs = s.construct_arguments([], {}, {'a': 11, 'b': 12, 'c': 7})
    assert args == []
    assert kwargs == {'a': 11, 'b': 12, 'c': 7}
開發者ID:IDSIA,項目名稱:sacred,代碼行數:5,代碼來源:test_signature.py

示例11: test_construct_arguments_does_not_overwrite_args_and_kwargs

def test_construct_arguments_does_not_overwrite_args_and_kwargs():
    s = Signature(bariza)
    args, kwargs = s.construct_arguments([1, 2], {'c': 3},
                                         {'a': 6, 'b': 6, 'c': 6})
    assert args == [1, 2]
    assert kwargs == {'c': 3}
開發者ID:IDSIA,項目名稱:sacred,代碼行數:6,代碼來源:test_signature.py

示例12: test_construct_arguments_ignores_excess_options

def test_construct_arguments_ignores_excess_options():
    s = Signature(bariza)
    args, kwargs = s.construct_arguments([2], {'b': 4},
                                         {'c': 6, 'foo': 9, 'bar': 0})
    assert args == [2]
    assert kwargs == {'b': 4, 'c': 6}
開發者ID:IDSIA,項目名稱:sacred,代碼行數:6,代碼來源:test_signature.py

示例13: test_construct_arguments_with_kwargs_for_posargs_does_not_raise

def test_construct_arguments_with_kwargs_for_posargs_does_not_raise():
    Signature(bariza).construct_arguments([], {'a': 4, 'b': 3, 'c': 2}, {})
    s = Signature(FunCTIonWithCAPItals)
    s.construct_arguments([], {'a': 4, 'b': 3, 'c': 2, 'd': 6}, {})
開發者ID:IDSIA,項目名稱:sacred,代碼行數:4,代碼來源:test_signature.py

示例14: test_construct_arguments_with_expected_kwargs_does_not_raise

def test_construct_arguments_with_expected_kwargs_does_not_raise():
    s = Signature(complex_function_name)
    s.construct_arguments([], {'a': 4, 'b': 3, 'c': 2}, {})
    s = Signature(FunCTIonWithCAPItals)
    s.construct_arguments([1, 2], {'c': 5}, {})
開發者ID:IDSIA,項目名稱:sacred,代碼行數:5,代碼來源:test_signature.py

示例15: test_construct_arguments_without_duplicates_passes

def test_construct_arguments_without_duplicates_passes():
    s = Signature(bariza)
    s.construct_arguments([1, 2], {'c': 5}, {})

    s = Signature(complex_function_name)
    s.construct_arguments([1], {'b': 4}, {})
開發者ID:IDSIA,項目名稱:sacred,代碼行數:6,代碼來源:test_signature_py3.py


注:本文中的sacred.config.signature.Signature類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。