예제 #1
0
def test_unequal_temperatures_raise_assertion_error(hdf5_dbase_root):
    first_ion = fiasco.Ion('Fe 12', [1e6, 1e7] * u.K,
                           hdf5_dbase_root=hdf5_dbase_root)
    second_ion = fiasco.Ion('Fe 9', [1e4, 1e5] * u.K,
                            hdf5_dbase_root=hdf5_dbase_root)
    with pytest.raises(AssertionError):
        fiasco.IonCollection(first_ion, second_ion)
예제 #2
0
def test_getitem(ion, another_ion, element, another_element):
    collection = fiasco.IonCollection(ion, another_ion, element, another_element)
    assert collection[0] == ion
    assert collection[1] == another_ion
    assert isinstance(collection[1:2], fiasco.IonCollection)
    assert collection[1:2][0] == another_ion
    assert isinstance(collection[:2], fiasco.IonCollection)
    for i in collection:
        assert isinstance(i, fiasco.Ion)
예제 #3
0
def test_spectrum_no_valid_ions(hdf5_dbase_root):
    # Consider the case of an collection with ions with no spectral information
    c2 = fiasco.IonCollection(
        fiasco.Ion('H 2', 1 * u.MK, hdf5_dbase_root=hdf5_dbase_root))
    with pytest.warns(UserWarning,
                      match='No transition data available for H 2'):
        with pytest.raises(
                ValueError,
                match=
                'No collision or transition data available for any ion in collection.'
        ):
            c2.spectrum(1e9 * u.cm**-3, 1e29 * u.cm**-5)
예제 #4
0
def test_create_with_wrong_type_raise_type_error(ion, collection):
    with pytest.raises(TypeError):
        fiasco.IonCollection(ion, 0)
    with pytest.raises(TypeError):
        collection + 0
예제 #5
0
def test_getitem(ion, another_ion):
    collection = fiasco.IonCollection(ion, another_ion)
    assert collection[0] == ion
    assert collection[1] == another_ion
예제 #6
0
def test_create_collection_from_collection(collection):
    assert isinstance(fiasco.IonCollection(collection), fiasco.IonCollection)
예제 #7
0
def test_create_collection_from_mixture(ion, element, collection):
    assert isinstance(ion + element + collection, fiasco.IonCollection)
    assert isinstance(fiasco.IonCollection(ion, element, collection),
                      fiasco.IonCollection)
예제 #8
0
def test_create_collection_from_elements(element, another_element):
    assert isinstance(element + another_element, fiasco.IonCollection)
    assert isinstance(fiasco.IonCollection(element, another_element),
                      fiasco.IonCollection)
예제 #9
0
def test_create_collection_from_ions(ion, another_ion):
    assert isinstance(ion + another_ion, fiasco.IonCollection)
    assert isinstance(fiasco.IonCollection(ion, another_ion),
                      fiasco.IonCollection)
예제 #10
0
def collection(hdf5_dbase_root):
    return fiasco.IonCollection(
        fiasco.Ion('H 1', temperature, hdf5_dbase_root=hdf5_dbase_root),
        fiasco.Ion('He 2', temperature, hdf5_dbase_root=hdf5_dbase_root))