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


Python Signature.construct_arguments方法代碼示例

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


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

示例1: test_construct_arguments_completes_kwargs_from_options

# 需要導入模塊: from sacred.config.signature import Signature [as 別名]
# 或者: from sacred.config.signature.Signature import construct_arguments [as 別名]
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,代碼行數:11,代碼來源:test_signature_py3.py

示例2: test_construct_arguments_with_duplicate_args_raises_typeerror

# 需要導入模塊: from sacred.config.signature import Signature [as 別名]
# 或者: from sacred.config.signature.Signature import construct_arguments [as 別名]
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])
開發者ID:IDSIA,項目名稱:sacred,代碼行數:12,代碼來源:test_signature_py3.py

示例3: test_construct_arguments_without_options_returns_same_args_kwargs

# 需要導入模塊: from sacred.config.signature import Signature [as 別名]
# 或者: from sacred.config.signature.Signature import construct_arguments [as 別名]
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}
開發者ID:IDSIA,項目名稱:sacred,代碼行數:17,代碼來源:test_signature_py3.py

示例4: test_construct_arguments_raises_if_args_unfilled

# 需要導入模塊: from sacred.config.signature import Signature [as 別名]
# 或者: from sacred.config.signature.Signature import construct_arguments [as 別名]
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,代碼行數:17,代碼來源:test_signature.py

示例5: test_construct_arguments_without_duplicates_passes

# 需要導入模塊: from sacred.config.signature import Signature [as 別名]
# 或者: from sacred.config.signature.Signature import construct_arguments [as 別名]
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,代碼行數:11,代碼來源:test_signature.py

示例6: test_construct_arguments_for_bound_method

# 需要導入模塊: from sacred.config.signature import Signature [as 別名]
# 或者: from sacred.config.signature.Signature import construct_arguments [as 別名]
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,代碼行數:7,代碼來源:test_signature.py

示例7: test_construct_arguments_does_not_raise_for_missing_defaults

# 需要導入模塊: from sacred.config.signature import Signature [as 別名]
# 或者: from sacred.config.signature.Signature import construct_arguments [as 別名]
def test_construct_arguments_does_not_raise_for_missing_defaults():
    s = Signature(complex_function_name)
    s.construct_arguments([], {}, {})
開發者ID:IDSIA,項目名稱:sacred,代碼行數:5,代碼來源:test_signature.py

示例8: test_construct_arguments_does_not_raise_if_all_args_filled

# 需要導入模塊: from sacred.config.signature import Signature [as 別名]
# 或者: from sacred.config.signature.Signature import construct_arguments [as 別名]
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,代碼行數:8,代碼來源:test_signature.py

示例9: test_construct_arguments_overwrites_defaults

# 需要導入模塊: from sacred.config.signature import Signature [as 別名]
# 或者: from sacred.config.signature.Signature import construct_arguments [as 別名]
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,代碼行數:7,代碼來源:test_signature.py

示例10: test_construct_arguments_does_not_overwrite_args_and_kwargs

# 需要導入模塊: from sacred.config.signature import Signature [as 別名]
# 或者: from sacred.config.signature.Signature import construct_arguments [as 別名]
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,代碼行數:8,代碼來源:test_signature.py

示例11: test_construct_arguments_ignores_excess_options

# 需要導入模塊: from sacred.config.signature import Signature [as 別名]
# 或者: from sacred.config.signature.Signature import construct_arguments [as 別名]
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,代碼行數:8,代碼來源:test_signature.py

示例12: test_construct_arguments_with_kwargs_for_posargs_does_not_raise

# 需要導入模塊: from sacred.config.signature import Signature [as 別名]
# 或者: from sacred.config.signature.Signature import construct_arguments [as 別名]
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,代碼行數:6,代碼來源:test_signature.py

示例13: test_construct_arguments_with_expected_kwargs_does_not_raise

# 需要導入模塊: from sacred.config.signature import Signature [as 別名]
# 或者: from sacred.config.signature.Signature import construct_arguments [as 別名]
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,代碼行數:7,代碼來源:test_signature.py

示例14: test_construct_arguments_without_duplicates_passes

# 需要導入模塊: from sacred.config.signature import Signature [as 別名]
# 或者: from sacred.config.signature.Signature import construct_arguments [as 別名]
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,代碼行數:8,代碼來源:test_signature_py3.py


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