コード例 #1
0
def test_abund(libsme, abund):
    """Test abundance behaviour"""
    libsme.InputAbund(abund)

    # TODO: What should be the expected behaviour?
    empty = Abund(monh=0, pattern="empty")
    empty.update_pattern({"H": 12})
    libsme.InputAbund(empty)

    with pytest.raises(TypeError):
        libsme.InputAbund(None)
コード例 #2
0
ファイル: test_abund.py プロジェクト: AWehrhahn/SME
def test_update_pattern():
    """Test behavior of update_pattern(), which modifies values in _pattern
    for the specified element(s).
    """
    # Update for one element yields float with the specified value.
    abund = Abund(pattern="Empty", monh=0)
    assert np.isnan(abund["Fe"])
    abund.update_pattern({"Fe": "3.14"})
    assert isinstance(abund["Fe"], float)
    assert abund["Fe"] == 3.14

    # Update for two elements yields floats with the specified values.
    abund.update_pattern({"C": 8.4, "F": 5})
    assert isinstance(abund["C"], float)
    assert isinstance(abund["F"], float)
    assert abund["C"] == 8.4
    assert abund["F"] == 5.0